[fpc-devel] Unicode support (yet again)
Marco van de Voort
marcov at stack.nl
Sun Sep 18 11:50:05 CEST 2011
In our previous episode, Fl?vio Etrusco said:
>
> That's somewhat what I was thinking. Actually something like
>
> UnicodeString = object
> strict private
> FEncoding: Integer;
> FBuffer: AnsiString;
> function GetCodePointAt(AIndex: SizeInt): Integer;
> procedure SetCodePoint(AIndex: SizeInt; p_Value: Integer);
> public
> property CodePoint[AIndex: SizeInt]: Integer read GetCodePointAt
> write SetCodePoint; default;
> end;
>
> I just don't whether something like this is already implemented in the
> test branches, at least for -err- testing...
Such ability is not unique for an object. One can also do something like
that with a native type. It was discussed and rejected.
The trouble is that it is not that easy, consider the first thing a
long time pascal user will do is fix his existing code which has many
constructs that loop over a string:
setlength(s2,s1);
for i:=1 to length(s1) do
s2[i]:=s1[i];
Now, to return codepoint[i], you need to parse all codepoints before [i].
So instead of O(n) this loop suddenly becomes O(n^2)....
More information about the fpc-devel
mailing list