[Lazarus] Problem encode UTF8 with BOM in unit

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Wed Jan 25 03:48:50 CET 2012


2012/1/25 Zaher Dirkey <parmaja at gmail.com>:
> How can i resolve this problem, because i share this unit with Delphi 2007,
> Delphi 2007 not understand UTF8 without BOM

For FPC up to 2.6 you can use all text fields as ansistring variables
and use ifdefs to call a procedure to convert all UTF-8 strings to
Ansi only in Delphi, see this unit from the Magnifier which does
exactly this:

http://magnifier.svn.sourceforge.net/viewvc/magnifier/trunk/translationsvmg.pas?revision=210&view=markup
See there procedure TTranslations.UpdateTranslations;

If you are using FPC 2.7 try keeping the BOM and add this call before
Application.Initialize:

SetMultiByteConversionCodePage(CP_UTF8);

-- 
Felipe Monteiro de Carvalho




More information about the Lazarus mailing list