Unit BGRAUTF8

📄 Source code

Description

UTF8 related functions

Uses

Overview

Structures

Name Description
Packed Record TBidiUTF8Info Unicode layout information along with offset for each UTF8 character
Record TGlyphCursorUtf8 Cursor to go through a UTF8 text glyph by glyph.
Record TGlyphUtf8 Information about one glyph in a UTF8 text

Functions and Procedures

function AddParagraphBidiUTF8(s: string; ARightToLeft: boolean): string;
function AnalyzeBidiUTF8(const sUTF8: string; ARightToLeft: boolean): TBidiUTF8Array; overload;
function AnalyzeBidiUTF8(const sUTF8: string; ABidiMode: TFontBidiMode): TBidiUTF8Array; overload;
function AnalyzeBidiUTF8(const sUTF8: string): TBidiUTF8Array; overload;
function ContainsBidiIsolateOrFormattingUTF8(const sUTF8: string): boolean;
function DeleteFileUTF8(Const FileName : string): boolean;
function FileCreateUTF8(Const FileName : string; Rights: LongWord) : THandle; overload;
function FileCreateUTF8(Const FileName : string) : THandle; overload;
function FileExistsUTF8(Const FileName : string): boolean;
function FileOpenUTF8(Const FileName : string; Mode : Integer) : THandle;
procedure FindCloseUTF8(var F: TSearchrec);
function FindFirstUTF8(const Path: string; Attr: Longint; out Rslt: TSearchRec): Longint;
function FindNextUTF8(var Rslt: TSearchRec): Longint;
function GetBidiClassUTF8(P: PChar): TUnicodeBidiClass;
function GetFirstStrongBidiClassUTF8(const sUTF8: string): TUnicodeBidiClass;
function GetLastStrongBidiClassUTF8(const sUTF8: string): TUnicodeBidiClass;
function GetUTF8DisplayOrder(const ABidi: TBidiUTF8Array): TUnicodeDisplayOrder;
function IsRightToLeftUTF8(const sUTF8: string): boolean;
function IsZeroWidthUTF8(const sUTF8: string): boolean;
function LEReadByte(Stream: TStream): byte;
function LEReadInt64(Stream: TStream): int64;
function LEReadLongint(Stream: TStream): longint;
function LEReadSingle(Stream: TStream): single;
procedure LEWriteByte(Stream: TStream; AValue: Byte);
procedure LEWriteInt64(Stream: TStream; AValue: int64);
procedure LEWriteLongint(Stream: TStream; AValue: LongInt);
procedure LEWriteSingle(Stream: TStream; AValue: single);
procedure LoadStringsFromFileUTF8(List: TStrings; const FileName: string);
procedure SaveStringsToFileUTF8(List: TStrings; const FileName: string);
function SysToUTF8(const s: string): string;
function UnicodeCharToUTF8(u: LongWord): string4;
function UTF16ToUTF8(const S: UnicodeString): AnsiString;
function UTF8CharacterLength(p: PChar): integer;
function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar;
function UTF8CodepointToUnicode(p: PChar; ACodePointLen: integer): LongWord;
function UTF8CompareStr(const S1, S2: string): Integer;
function UTF8CompareText(const S1, S2: string): Integer;
function UTF8EmbedDirection(const sUTF8: string; ARightToLeft: boolean): string;
function UTF8Length(p: PChar; ByteCount: PtrInt): PtrInt; overload;
function UTF8Length(const s: string): PtrInt; overload;
function UTF8Ligature(const sUTF8: string; ARightToLeft: boolean; ALigatureLeft, ALigatureRight: boolean): string;
function UTF8LowerCase(const s: string): string;
function UTF8OverrideDirection(const sUTF8: string; ARightToLeft: boolean): string;
function UTF8ReverseString(const s: string): string;
function UTF8ToSys(const s: string): string;
procedure UTF8ToUnicodeArray(const sUTF8: string; out u: TUnicodeArray; out ofs: TIntegerArray);
function UTF8ToUTF16(const S: AnsiString): UnicodeString;
function UTF8UpperCase(const s: string): string;

Types

string4 = string[4];
TBidiUTF8Array = packed array of TBidiUTF8Info;
TFileStreamUTF8 = TFileStream;
TIntegerArray = array of integer;
TStringListUTF8 = TStringList;
TUnicodeArray = packed array of LongWord;
TUnicodeBidiInfo = BGRAUnicode.TUnicodeBidiInfo;
TUnicodeDisplayOrder = BGRAUnicode.TUnicodeDisplayOrder;

Constants

UTF8_ARABIC_ALEPH = 'ا';
UTF8_ARABIC_ALEPH_HAMZA_ABOVE = 'أ';
UTF8_ARABIC_ALEPH_HAMZA_BELOW = 'إ';
UTF8_ARABIC_ALEPH_MADDA_ABOVE = 'آ';
UTF8_ARABIC_LAM = 'ل';
UTF8_LINE_SEPARATOR = #$E2#$80#$A8;
UTF8_NEXT_LINE = #$C2#$85;
UTF8_NO_BREAK_SPACE = ' ';
UTF8_PARAGRAPH_SEPARATOR = #$E2#$80#$A9;
UTF8_ZERO_WIDTH_JOINER = '‍';
UTF8_ZERO_WIDTH_NON_JOINER = '‌';

Description

Functions and Procedures

function AddParagraphBidiUTF8(s: string; ARightToLeft: boolean): string;

This item has no description.

function AnalyzeBidiUTF8(const sUTF8: string; ARightToLeft: boolean): TBidiUTF8Array; overload;

Returns an array with bidirectional analysis with specified text direction.

function AnalyzeBidiUTF8(const sUTF8: string; ABidiMode: TFontBidiMode): TBidiUTF8Array; overload;

Returns an array with bidirectional analysis with specified text direction.

function AnalyzeBidiUTF8(const sUTF8: string): TBidiUTF8Array; overload;

Returns an array with bidirectional analysis with automatic text direction.

function ContainsBidiIsolateOrFormattingUTF8(const sUTF8: string): boolean;

This item has no description.

function DeleteFileUTF8(Const FileName : string): boolean;

This item has no description.

function FileCreateUTF8(Const FileName : string; Rights: LongWord) : THandle; overload;

This item has no description.

function FileCreateUTF8(Const FileName : string) : THandle; overload;

This item has no description.

function FileExistsUTF8(Const FileName : string): boolean;

This item has no description.

function FileOpenUTF8(Const FileName : string; Mode : Integer) : THandle;

This item has no description.

procedure FindCloseUTF8(var F: TSearchrec);

This item has no description.

function FindFirstUTF8(const Path: string; Attr: Longint; out Rslt: TSearchRec): Longint;

This item has no description.

function FindNextUTF8(var Rslt: TSearchRec): Longint;

This item has no description.

function GetBidiClassUTF8(P: PChar): TUnicodeBidiClass;

This item has no description.

function GetFirstStrongBidiClassUTF8(const sUTF8: string): TUnicodeBidiClass;

This item has no description.

function GetLastStrongBidiClassUTF8(const sUTF8: string): TUnicodeBidiClass;

This item has no description.

function GetUTF8DisplayOrder(const ABidi: TBidiUTF8Array): TUnicodeDisplayOrder;

Display order of characters.

For example, a text in hebrew will be displayed from right to left. This function doesn't take into account word wrap. In this case, it is a bit more complicated and there is BGRATextBidi unit to handle text layout.)

function IsRightToLeftUTF8(const sUTF8: string): boolean;

This item has no description.

function IsZeroWidthUTF8(const sUTF8: string): boolean;

This item has no description.

function LEReadByte(Stream: TStream): byte;

This item has no description.

function LEReadInt64(Stream: TStream): int64;

little endian stream functions

function LEReadLongint(Stream: TStream): longint;

This item has no description.

function LEReadSingle(Stream: TStream): single;

This item has no description.

procedure LEWriteByte(Stream: TStream; AValue: Byte);

This item has no description.

procedure LEWriteInt64(Stream: TStream; AValue: int64);

This item has no description.

procedure LEWriteLongint(Stream: TStream; AValue: LongInt);

This item has no description.

procedure LEWriteSingle(Stream: TStream; AValue: single);

This item has no description.

procedure LoadStringsFromFileUTF8(List: TStrings; const FileName: string);

This item has no description.

procedure SaveStringsToFileUTF8(List: TStrings; const FileName: string);

This item has no description.

function SysToUTF8(const s: string): string;

This item has no description.

function UnicodeCharToUTF8(u: LongWord): string4;

This item has no description.

function UTF16ToUTF8(const S: UnicodeString): AnsiString;

This item has no description.

function UTF8CharacterLength(p: PChar): integer;

This item has no description.

function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar;

This item has no description.

function UTF8CodepointToUnicode(p: PChar; ACodePointLen: integer): LongWord;

This item has no description.

function UTF8CompareStr(const S1, S2: string): Integer;

This item has no description.

function UTF8CompareText(const S1, S2: string): Integer;

This item has no description.

function UTF8EmbedDirection(const sUTF8: string; ARightToLeft: boolean): string;

Adds special unicode characters to make it a quote in a specific direction. For example you can add a quote in arabic that will be right to left inside a text in latin alphabet. This is useful for example if there is punctiation at the end of the quote, so that it will be displayed on the correct side of the text.

function UTF8Length(p: PChar; ByteCount: PtrInt): PtrInt; overload;

This item has no description.

function UTF8Length(const s: string): PtrInt; overload;

This item has no description.

function UTF8Ligature(const sUTF8: string; ARightToLeft: boolean; ALigatureLeft, ALigatureRight: boolean): string;

This item has no description.

function UTF8LowerCase(const s: string): string;

This item has no description.

function UTF8OverrideDirection(const sUTF8: string; ARightToLeft: boolean): string;

Adds special unicode characters around the text to change it's direction. For example "hello" from right to left would be displayed as "olleh".

function UTF8ReverseString(const s: string): string;

This item has no description.

function UTF8ToSys(const s: string): string;

This item has no description.

procedure UTF8ToUnicodeArray(const sUTF8: string; out u: TUnicodeArray; out ofs: TIntegerArray);

This item has no description.

function UTF8ToUTF16(const S: AnsiString): UnicodeString;

This item has no description.

function UTF8UpperCase(const s: string): string;

This item has no description.

Types

string4 = string[4];

This item has no description.

TBidiUTF8Array = packed array of TBidiUTF8Info;

Array of unicode layout for UTF8 text

TFileStreamUTF8 = TFileStream;

File stream supporting UTF8 filenames

TIntegerArray = array of integer;

This item has no description.

TStringListUTF8 = TStringList;

String list supporting UTF8 filenames

TUnicodeArray = packed array of LongWord;

This item has no description.

TUnicodeBidiInfo = BGRAUnicode.TUnicodeBidiInfo;

Bidirectional layout information for one Unicode character

TUnicodeDisplayOrder = BGRAUnicode.TUnicodeDisplayOrder;

This item has no description.

Constants

UTF8_ARABIC_ALEPH = 'ا';

This item has no description.

UTF8_ARABIC_ALEPH_HAMZA_ABOVE = 'أ';

This item has no description.

UTF8_ARABIC_ALEPH_HAMZA_BELOW = 'إ';

This item has no description.

UTF8_ARABIC_ALEPH_MADDA_ABOVE = 'آ';

This item has no description.

UTF8_ARABIC_LAM = 'ل';

This item has no description.

UTF8_LINE_SEPARATOR = #$E2#$80#$A8;

This item has no description.

UTF8_NEXT_LINE = #$C2#$85;

equivalent of </p>

UTF8_NO_BREAK_SPACE = ' ';

This item has no description.

UTF8_PARAGRAPH_SEPARATOR = #$E2#$80#$A9;

equivalent of <br>

UTF8_ZERO_WIDTH_JOINER = '‍';

This item has no description.

UTF8_ZERO_WIDTH_NON_JOINER = '‌';

This item has no description.