[fpc-devel] Unicode resourcestrings

Daniël Mantione daniel.mantione at freepascal.org
Fri Feb 29 10:07:29 CET 2008



Op Fri, 29 Feb 2008, schreef Martin Schreiber:

> On Friday 29 February 2008 09.25:18 Daniël Mantione wrote:
>> Op Fri, 29 Feb 2008, schreef Martin Schreiber:
>>> On Friday 29 February 2008 09.02:02 Daniël Mantione wrote:
>>>> Op Fri, 29 Feb 2008, schreef Martin Schreiber:
>>>>> Hi,
>>>>> Is there a way in current FPC to have unicode or wide resourcestrings?
>>>>> Thanks,
>>>>
>>>> Resourcestrings are ansistrings, so the answer is no. This is indeed a
>>>> shortcoming in a widestring environment, the only solution is probably
>>>> to encode them UTF-8.
>>>
>>> This works with utf-8 system encoding only -> not in an usual Windows
>>> installation.
>>
>> There is utf8decode/utf8encode.
>>
> The big advantage of resourcestrings is that they can be used like normal
> string constants in the source. If I need to call utf8encode for every used
> stringconstant I can use the MSEgui widestring stockcaption facility instead.
>
>>> Are there plans to implement unicode resourcestrings?
>>
>> No, but this is just because you are the first one to ask. Could you make
>> a proposal? Then we'll see how this can be implemented.
>>
> Ideally from my point of view would be if the resourcestrings are stored in
> utf-8 if the unit is compiled with -Fcutf8 and decoded by utf8decode for
> widestring assignment on runtime independent of the system encoding.

This has been discussed before. Automatic conversion to/from ansistrings 
will always be to/from system encoding. If you want another encoding than 
the system encoding you will have to do a manual conversion.

For the compiler, a resourcestring has the same type as an ansistring, so 
no distinction can be made between resourcestrings/ansistrings.

Daniël


More information about the fpc-devel mailing list