Unit CastleUnicode

Description

Unicode utilities.

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TUnicodeCharList  

Functions and Procedures

function UTF8CharacterLength(p: PChar): integer;
function UTF8Length(const s: string): PtrInt; overload;
function UTF8Length(p: PChar; ByteCount: PtrInt): PtrInt; overload;
function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar;
function UTF8Copy(const s: string; StartCharIndex, CharCount: PtrInt): string;
function UTF8CharacterToUnicode(p: PChar; out CharLen: integer): TUnicodeChar;
function UnicodeToUTF8(CodePoint: TUnicodeChar): string;
function UnicodeToUTF8Inline(CodePoint: TUnicodeChar; Buf: PChar): integer;

Types

TUnicodeChar = Cardinal;

Description

Functions and Procedures

function UTF8CharacterLength(p: PChar): integer;
 
function UTF8Length(const s: string): PtrInt; overload;
 
function UTF8Length(p: PChar; ByteCount: PtrInt): PtrInt; overload;
 
function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar;
 
function UTF8Copy(const s: string; StartCharIndex, CharCount: PtrInt): string;
 
function UTF8CharacterToUnicode(p: PChar; out CharLen: integer): TUnicodeChar;

Return unicode character pointed by P. CharLen is set to 0 only when pointer P is Nil, otherwise it's always > 0.

The typical usage of this is to iterate over UTF-8 string char-by-char, like this:

var
  C: TUnicodeChar;
  TextPtr: PChar;
  CharLen: Integer;
begin
  TextPtr := PChar(S);
  C := UTF8CharacterToUnicode(TextPtr, CharLen);
  while (C > 0) and (CharLen > 0) do
  begin
    Inc(TextPtr, CharLen);
    // here process C...
    C := UTF8CharacterToUnicode(TextPtr, CharLen);
  end;
end;

function UnicodeToUTF8(CodePoint: TUnicodeChar): string;

function UTF8CharacterToUnicode(const S: string): TUnicodeChar;

function UnicodeToUTF8Inline(CodePoint: TUnicodeChar; Buf: PChar): integer;
 

Types

TUnicodeChar = Cardinal;
 

Generated by PasDoc 0.15.0.