On Mon, 09 Apr 2012 19:23:08 +0200 Jürgen Hestermann <[email protected]> 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. Mattias -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
