🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internationalization
Article #309

UTF8Decode Problem

#309
From: g
Date: Tue, 24 Aug 2004 04:16
22 lines
1731 bytes
Hi, I'm not knowing if I post to the correct board, if not, pls forward the question for me.

I have an application that read a text file which contains UTF8 characters.  It can be any language in the text file and the program need not know what language it will be.  The problem that I experienced is that when use TStrings to read a line and display on the ListBox1, some of the characters are encoded correctly, but some characters display in question mark (?).

The following is my code:

TStringList *c = new TStringList;
c->LoadFromFile("b.txt");
TStrings *a = new TStringList;
a->CommaText = c->Strings[0];
AnsiString UTF8Str = a->Strings[0];
WideString ws = UTF8Decode(UTF8Str);
ListBox1->Items->Add(AnsiString(ws));

I have looked at the value of ws when breakpoint, it shows, for example,
\x559C\x7231\x5F71\x7247\x522B
There are 5 characters, the 1,3,4 characters display correct, but the 2,5 characters display (?).

Please give any comment.

Best regards,
grace
Technical Details
Message-ID: <412ac101$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!newsfeed.iinet.net.au!newsfeed.iinet.net.au!PeerFeed.KWeb.on.ca!news.kweb.on.ca!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10297d,f2c293d7982a2280,start
X-Google-Attributes: gid10297d,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "g" <gmyc@hotmail.com>
Sender: "g" <gmyc@hotmail.com>
Reply-To: "g" <gmyc@hotmail.com>
Subject: UTF8Decode Problem
Newsgroups: borland.public.cppbuilder.internationalization
X-User-Info: 203.80.236.62     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <412ac101$1@newsgroups.borland.com>
Date: 23 Aug 2004 21:16:01 -0700
X-Trace: newsgroups.borland.com 1093320961 207.105.83.66 (23 Aug 2004 21:16:01 -0700)
Lines: 24
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!newsfeed.iinet.net.au!newsfeed.iinet.net.au!PeerFeed.KWeb.on.ca!news.kweb.on.ca!newsgroups.borland.com!not-for-mail