Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-07

How to get programatically a UTF8 encoded string?

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luiz Americo Pereira Camara

I tried to get UTF8 encoded strings programatically by doing

    Key := UTF8Encode('ç');
    Str := UTF8Encode('Ç');

but when i test the code below it will fail, unlike when using know UTF8 encoded strings

    if WideCompareText(UTF8Decode(Key), UTF8Decode(Str)) = 0 then
      WriteLn('  WideCompareText OK');

Any hint on how to get UTF8 encoded strings at runtime?

Luiz

Reply by email

JoshyFun
to Luiz Americo Pereira Camara

Hello FPC-Pascal,

Tuesday, July 21, 2009, 9:33:20 PM, you wrote:

LAPC> I tried to get UTF8 encoded strings programatically by doing LAPC> Key := UTF8Encode('ç');
LAPC> Str := UTF8Encode('Ç');
LAPC> but when i test the code below it will fail, unlike when using know UTF8 LAPC> encoded strings
LAPC> Any hint on how to get UTF8 encoded strings at runtime?

Check your current source code format, this means the encoding of your .pas file, quite sure it is still UTF-8, so simply:

Key := 'ç';

Right click -> File settings -> Encoding

Best regards, JoshyFun

Reply by email