[fpc-pascal] UTF8 codepage for file in trunk: codepage constant names?
Jonas Maebe
jonas.maebe at elis.ugent.be
Wed Jan 8 17:17:58 CET 2014
On 08 Jan 2014, at 15:58, Reinier Olislagers wrote:
> I'm trying to avoid ambiguity for an UTF8 (without BOM) encoded file
> and
> tried this:
> {$ifdef fpc}
> //Explicitly specify this is an UTF8 encoded file.
> //Alternative would be UTF8 with BOM but writing UTF8 BOM is bad
> practice.
> //See
> http://wiki.lazarus.freepascal.org/
> FPC_Unicode_support#String_constants
> {$codepage 65001} //utf8
> {$endif fpc}
>
> However, I get
> stringtests.pas(5,4) Error: Unknown codepage "65001"
The codepage names used by the codepage directive are (unfortunately,
I guess) unrelated to the code page numbers: http://www.freepascal.org/docs-html/prog/progsu88.html
They are the names of individual codepage units exposed by the charset
unit, which have names such as cp866 and cp1251. In fact, in general I
think you can just prefix the code page number with "cp" (other than
for utf8, which is built into the compiler and can be accessed via
utf8 or utf-8).
Note that this codepage functionality has been in FPC since 2.4.x
already (or maybe 2.6.0). It's not new in any way.
Jonas
More information about the fpc-pascal
mailing list