Record TCastleStringIterator

Unit

Declaration

type TCastleStringIterator = record

Description

Iterate over String that contains Unicode characters suitable for both FPC (with default String = AnsiString) and Delphi (with default String = UnicodeString).

This should be used for all iteration over strings in Castle Game Engine. It abstracts away various details about UTF-8 processing (in case of FPC) and UTF-16 processing (in case of Delphi). See https://castle-engine.io/coding_conventions#strings_unicode .

The typical usage looks like this:

var
  Iter: TCastleStringIterator;
begin
  Iter.Start('my_string');
  while Iter.GetNext do
  begin
    // do something with Iter.Current now
    WritelnLog('Got Unicode character: %d, %s', [
      Iter.Current,
      UnicodeCharToString(Iter.Current)
    ]);
  end;
end;

It is allowed to use Start again, with the same iterator (regardless if it finished or not), to start processing a new (or the same) String.

Source: base/castleunicode.pas (line 192).


Generated by PasDoc 0.17.0.snapshot.