[Lazarus] Unicode on Windows
Marcos Douglas
md at delfire.net
Mon Apr 9 21:59:57 CEST 2012
On Mon, Apr 9, 2012 at 3:39 PM, Mattias Gaertner
<nc-gaertnma at netcologne.de> wrote:
>
> On Mon, 09 Apr 2012 19:23:08 +0200
> Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
>
> > Marcos Douglas schrieb:
> > > Lenght function do not works with UTF8 correctly.
> > > procedure TForm1.Button1Click(Sender: TObject);
> > > begin
> > > Edit1.Text := 'ábç';
> > > ShowMessage(IntToStr(Length(Edit1.Text)));
> > > end;
> > > The result is 5 not 3, but you did know this of course.
> >
> >
> > Yes. For Unicode encoding we would need new functions to distinguish
> > between number of bytes and number of (visible) glyphs:
> >
> > LengthInBytes()
> > LengthInGlyphs()
> >
> > because sometimes you need the first and sometimes (but seldom) you need
> > the latter. For one byte encodings both are identical but not for
> > Unicode. Just think of LENGTH as beeing the first version.
>
> Length = size in bytes
> UTF8Length = number of code points
>
> There is no generic function LengthInGlyphs, because this depends on the
> font engine and some code points do not have a glyph.
In the future, we will transform UTF8Length deprecated, only use
Length function and the FPC will know wich the correct codepage use,
or it is not going happen never? =)
Marcos Douglas
More information about the Lazarus
mailing list