[Lazarus] UTF8 RTL for Windows

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Nov 25 14:45:07 CET 2014


On Tue, 25 Nov 2014 11:53:00 +0100
Hans-Peter Diettrich <DrDiettrich1 at aol.com> wrote:

>[...]
> > Correction: *This* Char type needs to be extended.
> 
> Please specify.

The ThousandSeparator type is "Char", which does not work with
Russian in UTF-8. Well, at least if you want the non breakable space
instead of the normal space.
There are many cases where Char is enough.

 
>[...] > "Char" in general is very useful.
> ...> 
> >> at least if it has less 
> >> than 3 bytes (4 for UTF-8). There exist many more flaws in the RTL/LCL, 
> >> assuming that a character always fits into a Char (like the Pos 
> >> overload...).
> > 
> > There is a Pos overload for strings. Where is the flaw in Pos?
> 
> The flaw is the added overload with a Char parameter.

I use that a lot. It is faster than the string variant.
Why is that a flaw?

> Furthermore the Pos arguments should never be subject to automatic 
> conversion, otherwise the returned index will be useless.

You can argue the same way in the direction: If it does not
automatically convert it will find crap.

 
> >> In the best case Char could be retyped into an string (substring),
> > 
> > That would be wrong in 99.9% of the cases.
> 
> Please give at least one example.

Retype "Char" to "String" and the compiler will bark. For example in
Graphics.

Mattias




More information about the Lazarus mailing list