使用delphi xe将iso_8859_1字符串转换为win1253

时间:2011-03-17 17:58:45

标签: delphi encoding delphi-xe

如何使用delphi xe进行此转换? 我尝试过使用libiconv2但没有用。

1 个答案:

答案 0 :(得分:5)

最好使用Dephi内置的AnsiString charset支持:

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;