[fpc-pascal] 2.5.1: Ansi string constants vs Unicode
Martin
fpc at mfriebe.de
Sat Jul 10 23:13:38 CEST 2010
On 10/07/2010 22:01, Jonas Maebe wrote:
>>> const Vec:AnsiString=#$094#$06D;
>>> This should just be 8-bit data with no conversion.
>>>
>> try const Vec:AnsiString=#$94#$6D;
>>
> I've now documented this change at http://wiki.freepascal.org/User_Changes_Trunk#Short.2FAnsistring_typed_constants_containing_widechars.2Funicodechars
>
>
from the page:
{$codepage utf8}
const
s1: shortstring = 'éà';
s2: ansistring = #$094#$06D;
s3: ansistring = #267#543;
In case of s2, s3 it's a do-able conversion, since the numeric values are already known.
But with s1 that could potentially be much much more work, and also very inconvenient for writing new code.
I would not know all the ordinal values from the top of my head, and if the string was long, it would mean to look up dozens of uni-codes.
It would be nice if there was(maybe there is) some way, of telling the compiler that the string is to be treaded as binary-data. Maybe like:
{$codepage utf8}
const
{$codepage binary} // temporary change
s1: shortstring = 'éà';
{$codepage utf8} // back to original
s2: ansistring = #$094#$06D;
s3: ansistring = #267#543;
More information about the fpc-pascal
mailing list