[fpc-pascal] Compile ANSI unit as UTF8
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Sep 6 15:42:39 CEST 2010
On 06 Sep 2010, at 15:30, Zaher Dirkey wrote:
> On Mon, Sep 6, 2010 at 11:16 AM, Jonas Maebe <jonas.maebe at elis.ugent.be
> >wrote:
>
>> The compiler itself can only convert from utf-8 and several ISO
>> code pages
>> into utf-16 at compile time (i.e., change string constants into
>> widestring
>> constants). If you want to convert them to utf-8, you have to use a
>> text
>> editor as Felipe mentioned.
>>
> Becuase i use this unit in Delphi 7 and Lazarus with my local
> language.
>
> What for -Fm<x> parameters?
Those tell the compiler that your source has been stored in that
particular code page, and then the compiler will convert all string
constants *from* the specified code page *to* widestring (which then
at run time is converted back to the active ANSI code page; not to
UTF-8).
If you want to do that, you have to wrap all your string constants
with utf8encode(). That takes a widestring as parameter and returns an
UTF-8 string. However, that is not Delphi-compatible either.
In the long term, native utf8string support will solve your problem,
but right now what you want is not possible afaik.
Jonas
More information about the fpc-pascal
mailing list