[Lazarus] How to use strings properly with fixes_1_6 and FPC 3.0.0?

Gabor Boros gaborboros at yahoo.com
Fri Oct 21 09:03:19 CEST 2016


Hi All,

In the past I used Length, Pos, Delete, for i:=1 to Length(s) do s[i]...
and realized yesterday these practices are wrong. But I do not know what 
the right practice.

Found UTF8* on "LCL Unicode Support" wiki page, later {$Codepage UTF8} 
on "Better Unicode Support in Lazarus".

The result of below lines:
2
2
1
1

With {$Codepage UTF8}:
2
1
1
1

I see same results with Linux and Windows.

UTF8* is good to me but a compiler directive is easier to use, just 
don't know why not working properly.

What is the proper way to read through (character after character) the 
string if use UTF8* procedures?

var
   s:String;

begin
   s:='á';
   Memo1.Lines.Add(IntToStr(Length(s)));
   Memo1.Lines.Add(IntToStr(Length('á')));

   Memo1.Lines.Add(IntToStr(UTF8Length(s)));
   Memo1.Lines.Add(IntToStr(UTF8Length('á')));


Gabor


More information about the Lazarus mailing list