[fpc-devel] for-in-index loop

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Jan 25 12:39:06 CET 2013


Michael Schnell <mschnell at lumino.de> hat am 25. Januar 2013 um 11:58
geschrieben:
> On 01/25/2013 11:23 AM, Mattias Gaertner wrote:
> > Do you mean codepoint? Printable depends on ligatures and other things.
>
> Both might be desirable. I don't want to define that. This will depend
> ´on the implementation of the indexer class.

Ligatures depend on the font. This is outside the scope of the RTL and
especially any compiler magic. A rendering library might implement such an
enumerator.


> >> Finding the 100000 th and then independently the 100005 th printable
> >> character needs quite a lot of CPU time
> > In UTF8, UTF16 and UTF32 it takes 5 steps.
> What do you mean by "steps" ?

I meant if you have the 100000th codepoint you can find the 100005th codepoint
in 5 steps.
With current compiler magic you can write an enumerator for this task.


> > There are plenty of functions for this. You can wrap them into
> > enumerators as demonstrated.
>
> In fact I easily could do my own implementation of the functionality if
> I would have the need for it.
>
> The question is whether it would make sens to provide a fast
> implementation of such a class in the RTL and offer some compiler magic
> to make it easily usable (e.g. for beginners) and compatible with
> possible future string types to prevent any porting effort of user code.

Please keep in mind that working with strings and working with Unicode are
different things.
The old simplicity of 8-bit codepages is a thing of the past. It was an
optimization that worked for a few small regions. Programmers must understand
that printed characters can not be represented by single numbers.

Mattias



More information about the fpc-devel mailing list