[Lazarus] Does Lazarus support a complete Unicode Component Library?

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Feb 16 13:59:32 CET 2011


Op 2011-02-16 14:25, Michael Schnell het geskryf:
> Yep. Bus as discussed here earlier, Length() - that needs to be done
> with the same paradigm as mystr[i] - is a problem. When using e.g.
> stream-I/O people will want it to be the byte count, when doing a loop
> along a string, they want it to be the unicode-character count.

This is why Length() can stay as is - returning a byte count. We can
then introduce a new StringIterator class or something that can return
one unicode-character at a time - for loop purposes. I have already
create such iterators for myself going through strings or any tyes of
list classes found in the RTL. Using such iterators instead of dump
for..loops, I can now move forward, backwards, skip elements, filter
elements etc... Such Iterators are very powerful and flexible.

eg:

var
  itr: IStringIterator;
  c: UnicodeChar;  // or something that can store at least 4 bytes
begin
  itr := TStringHelper.GetUnicodeIterator(MyString);
  while itr.HasNext do
  begin
    i := itr.Next
    ... now do something with the Unicode character stored in i
  end;
end;

This also reduces confusion. The developer knows what is being returned
simply by looking at the code, unlike the confusion with Length() [is it
number of chars or number of bytes].


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/





More information about the Lazarus mailing list