0

How can i do this conversion with delphi xe? I've tried using libiconv2 but didn't worked.

1
  • 1
    What does "didn't worked" mean? I can't tell what went wrong for you from where I'm sitting. Commented Mar 17, 2011 at 18:05

1 Answer 1

5

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; 
Sign up to request clarification or add additional context in comments.

2 Comments

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!
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.