Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to convert hexidecimal to AnsiString unicode

Status
Not open for further replies.

aeijohn

Programmer
Apr 5, 2006
3
US
What is best way to convert an hex unicode to AnsiString? Ideally, for me, the input would be hex code is in AnsiString with format of "u\ABCD"; output is AnsiString.
 
I tried this:

AnsiString st,su,sx;
.
.
su="00a9" //value varies when called
TCHAR sx[10];
sx[0]=NULL;
su="0x"+su;
wsprintf(sx,"%c",su.ToInt());
st+=sx;

which seems to works for 0x00a9, but gives garbage for 0x5b89 (represents Chinese character) when viewed in TList or TMemo (Font and Font Name = MS Sans Serif.)

Any ideas why 0x5b89 is not showned correctly?
 
If you do a Google search on Ansistring to Unicode characters, you'll get all sorts of good information on this.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top