Unicode output to UTF-8 text file problem
I can use the FM20.DLL control inside VB6 and the application can view / edit / add Simplified Chinese. However, when I export the data to a text file ,some Simplified character turned to ? instead of a valid Simplified Chinese
Value stored in the SQL2000 database is
滁州市发生建市
When export to a notepad text file, it output as
滁州市?建市
I checked through the internet and the ADO data control 6.0 did support unicode and I think it is the problem when it output to the notepad which I use an array to hold the data, code as below
===================================================
Dim o_Container
Open "ABC.TXT" for output as #1
o_Container(1) = adoh.recordset.fields("SimplifiedCharacter")
print #1, o_Container(1)
Print #1, adoh.recordset.fields("SimplifiedCharacter")
Close #1
===================================================
'ABC.TXT contains
滁州市?建市
滁州市?建市
===================================================
Where adoh.recordset.fields("SimplifiedCharacter") did hold the correct value "滁州市发生建市"
Thanks in advance
Re: Unicode output to UTF-8 text file problem
I tested using copy & paste some Simplified chinese from yahoo.com.hk and paste it to EXCEL and write a VBA macro to output to a text file, the result is same to my VB output, some display ?.
I think it is the problem on VB / VBA when export to a text file using
Open ABC.TXT for output as #1
Print #1 Cells(1,1) 'Where cells(1,1) contains simplified chinese
close #1
So, please post another method to export data to a text file
Thanks
Re: Unicode output to UTF-8 text file problem
i believe you need to put a BOM sequence at the beginning of your file, at least that worked when i tried to save some arabic
VB Code:
ReDim bom(5)
bom(0) = &HEF
bom(2) = &HBB
bom(4) = &HBF
Print #1, bom;
then continue with the code you posted above
to get more information see this thread http://www.vbforums.com/showthread.p...hlight=unicode
also look for post by merri he has some links in his signature