[Lazarus] Problem encode UTF8 with BOM in unit

Maxim Ganetsky ganmax at narod.ru
Wed Jan 25 21:47:25 CET 2012


25.01.2012 2:02, Zaher Dirkey пишет:
> Hi,
>
> I created new project, then choose "File Settings -> Encoding -> UTF8
> with BOM -> Change file"
>
> Added new listbox1 to the form, in source code (button ) i added some
> items with my local language, this language in run time apear like "??????".
>
> Is that a bug or i missed something?

When BOM or {$codepage utf8} directive is present compiler converts your 
strings to widestrings. So you have two options

1. Add {$codepage 8859-1} directive at the start of the .pas file.

2. Use UTF8Encode() function, e.g.

ListBox1.Items.Add(UTF8Encode('محاسبة عادية'));

-- 
Best regards,
  Maxim Ganetsky                  mailto:ganmax at narod.ru




More information about the Lazarus mailing list