How can i do this conversion with delphi xe? I've tried using libiconv2 but didn't worked.
1 Answer
Using Dephi's built-in AnsiString charset support is best:
type // ISO-8859-1 and Windows-1252 are NOT the same, but // are commonly interchanged when they should not be! Latin1String = type AnsiString(28591); Windows1252String = type AnsiString(1252); GreekString = type AnsiString(1253); procedure DoIt; var S1: Latin1String; S2: Windows1252String; S3: GreekString; begin S1 := '...'; // auto-converts to ISO-8859-1 S2 := S1; // auto-converts from ISO-8859-1 to Unicode to Windows-1252 S3 := S1; // auto-converts from ISO-8859-1 to Unicode to Greek end; 2 Comments
Arnaud Bouchez
This is indeed the easiest way of doing the conversion since Delphi 2009. You could use manual conversion via Windows API calls with previous version of Delphi: MultiByteToWideChar then WideCharToMultiByte - it's always better to call Windows API than libiconv2 which is NOT a standard under Windows!
Remy Lebeau
The Win32 API only supports charsets whose codepages are installed (.NET has some built-in support for additional charsets, but there are many charsets used in the world). libiconv is not limited by that restriction, and is available for install on Windows.