Sign in Join
FPDoc Onlineexperiment

LazUnicode unit

Provides encoding-agnostic Unicode string manipulation functions and an enumerator.

lazunicode.pas provides encoding-agnostic Unicode string manipulation functions and an enumerator. It works transparently with UTF-8 and UTF-16 encodings, and allows one codebase to work for:

  1. Lazarus using its default UTF-8 encoding
  2. Future FPC and Lazarus versions with Delphi compatible UTF-16 encoding
  3. Delphi compatibility where String is defined as UnicodeString
Behavior of helper functions are altered using the {$ModeSwitch UnicodeStrings} directive; the correct routines for handling UTF-8 or UTF-16 are called based on the mode switch value.

lazunicode.pas is part of the LazUtils package.

Classes and records

TCodePointEnumeratorclassBase class for a Unicode codepoint enumerator.
TUnicodeCharacterEnumeratorclassImplements an enumerator for Unicode codepoints.
TUnicodeEnumeratorBaseclassBase class for a Unicode character enumerator.

Procedures and functions

CodePointCopyfunctionCopies the specified number of codepoints starting at a character position.
CodePointLengthfunctionGets the number of codepoints in the specified string.
CodePointPosfunctionGets the position where the search value is found in a string.
CodePointSizefunctionGets the number of bytes needed for a CodePoint in the specified value.
enumerator(string):TUnicodeCharacterEnumeratoroperatorEnumerator which combines diacritical marks.
IsCombiningfunctionDetermines if the specified value is a combining codepoint.
StringOfCodePointfunctionCreates a string with the specified number of codepoints.
UnicodeToWinCPfunctionConverts the specified value to the Windows system codepage.
WinCPToUnicodefunctionConverts the specified string to Unicode.

Uses

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.