Recent

Author Topic: Canvas.Textout OEM codepage  (Read 5724 times)

Martin V

  • Full Member
  • ***
  • Posts: 139
Canvas.Textout OEM codepage
« on: July 14, 2010, 10:10:43 pm »
I tried to get a canvas text output in OEM (IBM 437/850) codepage which is for example used in the Windows commandline window. There are some special characters (e.g. for line drawing) which are not part of the ANSI (Windows default 1252) codepage. If I use Canvas.Textout, a UTF8 string is expected. Can I directly print OEM/ANSI strings or/and is it possible to convert a OEM coded string to UTF8 ?

Martin

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: Canvas.Textout OEM codepage
« Reply #1 on: July 14, 2010, 10:20:30 pm »
uses LConvEncoding;
...
var Astr:String;
begin
AStr:=#$C8#$C9#$CA;
Caption:=ConvertEncoding(AStr,'cp850',EncodingUTF8);
end;

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: Canvas.Textout OEM codepage
« Reply #2 on: July 18, 2010, 06:20:12 pm »
Thank you, the code works fine. I can understand the decision that UTF8 is the default string format in Lazarus. It can handle the characters of all existing codepages. That's really great.

Martin