[fpc-devel] Explanation about code page-aware AnsiStrings

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Jan 7 16:08:25 CET 2014


On 07 Jan 2014, at 15:54, Jy V wrote:

> n Tue, Jan 7, 2014 at 12:57 PM, Jonas Maebe <jonas.maebe at elis.ugent.be>wrote:
> 
>> For this reason I've created an overview that explains the rules that are
>> followed by the RTL/compiler at
>> http://wiki.freepascal.org/FPC_Unicode_support
> 
> "it is best to save the source code in UTF-8 with a BOM."

This is the full quote: "it is best to include either an explicit {$codepage xxx} directive or save the source code in UTF-8 with a BOM" (which I've now clarified a bit on the wiki page). Both are equally good as far as FPC is concerned.

> Is this recommendation is compatible with Delphi7, Delphi 2007 ?

Delphi doesn't know the {$codepage xxx} directive, but you can put it between {$ifdef fpc}. I don't know whether it automatically detects UTF-8-encoded files (or even handles them at all), especially these older versions. If it doesn't, you can still save your source code in any code page and add a {$codepage xxx} statement for FPC. Additionally, I forgot to mention that you can also specify the used code page on the command line with FPC, via the -Fc parameter.


Jonas


More information about the fpc-devel mailing list