As often happens, I managed to solve the problem after posting the question.

 

SetLength(WS,Length(S)div 2);

Move(S[1],WS[1],Length(S));

 

I was previously typecasting WideString(S) but of course that does some
unwanted conversion.

 

And then run WideCharToMultiByte with CP_ACP codepage and WC_COMPOSITECHECK
flag.

 

Ross.

 

From: Ross Levis [mailto:r...@stationplaylist.com] 
Sent: Monday, 15 November 2010 6:40 PM
To: Delphi Discussion List
Subject: UTF16 To ANSI ? 

 

I hope someone can help.  I'm using D7.  I have some UTF-16 Unicode
(Chinese) characters stored currently in an AnsiString variable.  I need to
display this correctly on a PC with Chinese language installed.

 

The Windows main language is set to English, but in the Advanced tab of the
Windows Regional & Language settings, the "Language for non-unicode
programs" is set to Chinese.

 

The string starts $FF $FE .

 

I can't seem to find the correct function to use.  I've tried
WideCharToString and WideCharToMultiByte without success.

 

Many thanks,

Ross.

_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to