Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.vb
external usenet poster
 
Posts: 3
Default Chinese characters - UTF8 CSV files

Hi All,

I'm facing problem while showing the Chinese characters in CSV file.
I'm using Open for Append Access Write As method to create the CSV file
programmatically. If I set the CSV file character set to UTF-8 then I
can display the Chinese characters. But I'm not able to set the CSV
character set to UTF-8 programmatically.

I'm using VB6.0 for this.

If anybody knows this please let me know. Thanks a lot in advance.

With love,
Manju

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Chinese characters - UTF8 CSV files

Hi Manju,
Write your csv file in first and try to convert it then into sending the
full path name of your file like argument to the procedure below:

Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
..Open
..LoadFromFile sPath ' Loads a File
..Charset SetChar ' sets stream encoding (UTF-8)
..SaveToFile sPath, 2 ' adSaveCreateOverWrite
..Close
End With
End Sub

Regards,
MP

a écrit dans le message de news:
...
Hi All,

I'm facing problem while showing the Chinese characters in CSV file.
I'm using Open for Append Access Write As method to create the CSV file
programmatically. If I set the CSV file character set to UTF-8 then I
can display the Chinese characters. But I'm not able to set the CSV
character set to UTF-8 programmatically.

I'm using VB6.0 for this.

If anybody knows this please let me know. Thanks a lot in advance.

With love,
Manju



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Chinese characters - UTF8 CSV files

Hi Michel,

Thanks a lot for the response. I'm getting "450 Wrong number of
arguments or invalid property assignment" error when I use the below
code.

Since I'm very new to VB, please bare with me. Thanks a lot in advance.

Regards,
Manjunath A.

Michel Pierron wrote:
Hi Manju,
Write your csv file in first and try to convert it then into sending the
full path name of your file like argument to the procedure below:

Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub

Regards,
MP

a écrit dans le message de news:
...
Hi All,

I'm facing problem while showing the Chinese characters in CSV file.
I'm using Open for Append Access Write As method to create the CSV file
programmatically. If I set the CSV file character set to UTF-8 then I
can display the Chinese characters. But I'm not able to set the CSV
character set to UTF-8 programmatically.

I'm using VB6.0 for this.

If anybody knows this please let me know. Thanks a lot in advance.

With love,
Manju


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Chinese characters - UTF8 CSV files

Re Manju,
Excuse me, there is an error of text in the procedure, one needs an equal
sign between .CharSet and SetChar:
..CharSet = SetChar ' sets stream encoding (UTF-8)

Regards,
MP

a écrit dans le message de news:
...
Hi Michel,

Thanks a lot for the response. I'm getting "450 Wrong number of
arguments or invalid property assignment" error when I use the below
code.

Since I'm very new to VB, please bare with me. Thanks a lot in advance.

Regards,
Manjunath A.

Michel Pierron wrote:
Hi Manju,
Write your csv file in first and try to convert it then into sending the
full path name of your file like argument to the procedure below:

Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub

Regards,
MP

a écrit dans le message de news:
...
Hi All,

I'm facing problem while showing the Chinese characters in CSV file.
I'm using Open for Append Access Write As method to create the CSV file
programmatically. If I set the CSV file character set to UTF-8 then I
can display the Chinese characters. But I'm not able to set the CSV
character set to UTF-8 programmatically.

I'm using VB6.0 for this.

If anybody knows this please let me know. Thanks a lot in advance.

With love,
Manju



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Chinese characters - UTF8 CSV files

Hi Michel,

That worked !! Thanks a lot.

But still I'm seeing "??" marks instead of chinese characters in CSV
file. Do you have any idea about this?

Thanks in advance.

Regards,
Manju

Michel Pierron wrote:
Re Manju,
Excuse me, there is an error of text in the procedure, one needs an equal
sign between .CharSet and SetChar:
.CharSet = SetChar ' sets stream encoding (UTF-8)

Regards,
MP

a écrit dans le message de news:
...
Hi Michel,

Thanks a lot for the response. I'm getting "450 Wrong number of
arguments or invalid property assignment" error when I use the below
code.

Since I'm very new to VB, please bare with me. Thanks a lot in advance.

Regards,
Manjunath A.

Michel Pierron wrote:
Hi Manju,
Write your csv file in first and try to convert it then into sending the
full path name of your file like argument to the procedure below:

Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub

Regards,
MP

a écrit dans le message de news:
...
Hi All,

I'm facing problem while showing the Chinese characters in CSV file.
I'm using Open for Append Access Write As method to create the CSV file
programmatically. If I set the CSV file character set to UTF-8 then I
can display the Chinese characters. But I'm not able to set the CSV
character set to UTF-8 programmatically.

I'm using VB6.0 for this.

If anybody knows this please let me know. Thanks a lot in advance.

With love,
Manju




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Chinese characters - UTF8 CSV files

Re Manju,
I do not have an idea for the moment about this, but to check, you could try
to generate your file through Notepad and to record it with format UTF-8.
To record a file with format UTF-8 using the Notepad, click on File To Save
as. Then, develop the list of options of the Codage zone and select UTF-8.

MP

a écrit dans le message de news:
...
Hi Michel,

That worked !! Thanks a lot.

But still I'm seeing "??" marks instead of chinese characters in CSV
file. Do you have any idea about this?

Thanks in advance.

Regards,
Manju

Michel Pierron wrote:
Re Manju,
Excuse me, there is an error of text in the procedure, one needs an equal
sign between .CharSet and SetChar:
.CharSet = SetChar ' sets stream encoding (UTF-8)

Regards,
MP

a écrit dans le message de news:
...
Hi Michel,

Thanks a lot for the response. I'm getting "450 Wrong number of
arguments or invalid property assignment" error when I use the below
code.

Since I'm very new to VB, please bare with me. Thanks a lot in advance.

Regards,
Manjunath A.

Michel Pierron wrote:
Hi Manju,
Write your csv file in first and try to convert it then into sending the
full path name of your file like argument to the procedure below:

Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub

Regards,
MP

a écrit dans le message de news:
...
Hi All,

I'm facing problem while showing the Chinese characters in CSV file.
I'm using Open for Append Access Write As method to create the CSV
file
programmatically. If I set the CSV file character set to UTF-8 then I
can display the Chinese characters. But I'm not able to set the CSV
character set to UTF-8 programmatically.

I'm using VB6.0 for this.

If anybody knows this please let me know. Thanks a lot in advance.

With love,
Manju



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Chinese characters - UTF8 CSV files

Re Manju,
I think that you could do something like that:
1- Create an empty file
2- Convert it with format UTF-8.
3- Append your data

Sub Create_UTF8_File()
Const File$ = "C:\FileTest.csv"
Dim Fso, MyFile
Set Fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = Fso.CreateTextFile(File, True)
MyFile.Close
With CreateObject("ADODB.Stream")
..Open
..LoadFromFile File
..Position = 0
..CharSet = "UTF-8"
..SaveToFile File, 2
..Close
End With
'Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set MyFile = Fso.OpenTextFile(File, 8, True, True)
' Just for the example:
MyFile.WriteLine ChrW(31532) & ChrW(&H4F60) & ChrW(&H597D) _
& ChrW(59) & ChrW(&H6771) & ChrW(&H4EAC)
MyFile.WriteLine ChrW(&H4EAC) & ChrW(&H90FD) & ChrW(59) _
& ChrW(&H65B0) & ChrW(&H6F5F) & ChrW(&H21)
MyFile.Close
Set MyFile = Nothing: Set Fso = Nothing
End Sub

Regards,
MP

a écrit dans le message de news:
...
Hi Michel,

That worked !! Thanks a lot.

But still I'm seeing "??" marks instead of chinese characters in CSV
file. Do you have any idea about this?

Thanks in advance.

Regards,
Manju

Michel Pierron wrote:
Re Manju,
Excuse me, there is an error of text in the procedure, one needs an equal
sign between .CharSet and SetChar:
.CharSet = SetChar ' sets stream encoding (UTF-8)

Regards,
MP

a écrit dans le message de news:
...
Hi Michel,

Thanks a lot for the response. I'm getting "450 Wrong number of
arguments or invalid property assignment" error when I use the below
code.

Since I'm very new to VB, please bare with me. Thanks a lot in advance.

Regards,
Manjunath A.

Michel Pierron wrote:
Hi Manju,
Write your csv file in first and try to convert it then into sending the
full path name of your file like argument to the procedure below:

Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub

Regards,
MP

a écrit dans le message de news:
...
Hi All,

I'm facing problem while showing the Chinese characters in CSV file.
I'm using Open for Append Access Write As method to create the CSV
file
programmatically. If I set the CSV file character set to UTF-8 then I
can display the Chinese characters. But I'm not able to set the CSV
character set to UTF-8 programmatically.

I'm using VB6.0 for this.

If anybody knows this please let me know. Thanks a lot in advance.

With love,
Manju



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Chinese characters - UTF8 CSV files

Re Manju,
Or more simply by creating one unicode file with fso

Sub Create_UTF8_File()
Const File$ = "C:\FileTest.csv"
Dim Fso, MyFile
Set Fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = Fso.CreateTextFile(File, True, True)
' Just for the example:
MyFile.WriteLine ChrW(31532) & ChrW(&H4F60) & ChrW(&H597D) _
& ChrW(59) & ChrW(&H6771) & ChrW(&H4EAC)
MyFile.WriteLine ChrW(&H4EAC) & ChrW(&H90FD) & ChrW(59) _
& ChrW(&H65B0) & ChrW(&H6F5F) & ChrW(&H21)
MyFile.Close
Set MyFile = Nothing: Set Fso = Nothing
End Sub

Regards,
MP

a écrit dans le message de news:
...
Hi Michel,

That worked !! Thanks a lot.

But still I'm seeing "??" marks instead of chinese characters in CSV
file. Do you have any idea about this?

Thanks in advance.

Regards,
Manju

Michel Pierron wrote:
Re Manju,
Excuse me, there is an error of text in the procedure, one needs an equal
sign between .CharSet and SetChar:
.CharSet = SetChar ' sets stream encoding (UTF-8)

Regards,
MP

a écrit dans le message de news:
...
Hi Michel,

Thanks a lot for the response. I'm getting "450 Wrong number of
arguments or invalid property assignment" error when I use the below
code.

Since I'm very new to VB, please bare with me. Thanks a lot in advance.

Regards,
Manjunath A.

Michel Pierron wrote:
Hi Manju,
Write your csv file in first and try to convert it then into sending the
full path name of your file like argument to the procedure below:

Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub

Regards,
MP

a écrit dans le message de news:
...
Hi All,

I'm facing problem while showing the Chinese characters in CSV file.
I'm using Open for Append Access Write As method to create the CSV
file
programmatically. If I set the CSV file character set to UTF-8 then I
can display the Chinese characters. But I'm not able to set the CSV
character set to UTF-8 programmatically.

I'm using VB6.0 for this.

If anybody knows this please let me know. Thanks a lot in advance.

With love,
Manju



  #9   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.vb
external usenet poster
 
Posts: 1
Default Chinese characters - UTF8 CSV files

Hello Manju,

the problem is that VB6 does not support UTF-8.
If you want to append then maybe you can use this method:

1. Open the file as binary
2. Get the characters value (AscW) and write it into a long variable.
3. Get the upper and lower byte values and store them in 2 byte variables.
4. Write those byte variables into your file.
5. For Carriage Return and line feed you have to write the 10 and 13
manually.

Best Regards,

HKSHK

wrote:
Hi All,

I'm facing problem while showing the Chinese characters in CSV file.
I'm using Open for Append Access Write As method to create the CSV file
programmatically. If I set the CSV file character set to UTF-8 then I
can display the Chinese characters. But I'm not able to set the CSV
character set to UTF-8 programmatically.

I'm using VB6.0 for this.

If anybody knows this please let me know. Thanks a lot in advance.

With love,
Manju

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chinese Characters ! John New Users to Excel 0 March 9th 07 11:24 PM
Entering Chinese characters into VBA source codes Ray Excel Programming 3 February 9th 06 03:20 PM
Exporting to CSV file with Chinese Characters in Spreadsheet Just Me Excel Discussion (Misc queries) 1 August 17th 05 11:37 AM
BUTTON CAPTION CHINESE CHARACTERS Souris Excel Programming 0 August 17th 05 03:46 AM
Chinese characters lazyboy Excel Discussion (Misc queries) 0 March 15th 05 04:19 AM


All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"