|
-
Jan 30th, 2007, 05:56 AM
#1
Thread Starter
New Member
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
-
Jan 30th, 2007, 07:16 AM
#2
Thread Starter
New Member
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
-
Jan 31st, 2007, 08:10 AM
#3
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|