Sign in Join
FPDoc Onlineexperiment

unicodedata unit

Unicode data management.

The fpwidestring unit relies on having relevant Unicode collation data linked in the binary. The Unicode data is managed using the routines in the unicodedata unit. The FPC project distributes some Unicode collation data in .bco files which can be loaded using the LoadCollation routines. The LoadCollation is the main routine of this unit.

All collation data requires at least the Default Unicode Collation Element Table to be registered (called DUCET). The DUCET encoding is provided by the unicodeducet unit, part of the rtl-Unicode package.

There are two ways to register collations :

  1. at compile time: by including the desired collation unit, for example for Russian and Japanese languages to be available you will have to include collation_ru and collation_ja from package "rtl-unicode".
  2. at runtime using the above mentioned LoadCollation function.

The two ways can co-exist: some collations may be compile time included (for example for most used collations) and others can be loaded at runtime in the same application.

The binary collation files are endian sensitive:

  • there are files for little endian systems named collation_lang_le.bco (such as collation_ru_le.bco and collation_ja_le.bco)
  • there are files for big endian systems named collation_lang_be.bco (such as collation_ru_be.bco and collation_ja_be.bco).

Note that the compile time units collation units (collation_lang.pas) include already the unicodeducet.pas (DUCET) unit so it is not necessary to include it manually, contrary to the binary files. So an application that only uses the binary collation files should at least include the unicodeducet unit or manually load the binary collation collation_ducet_le.bco or collation_ducet_be.bco, depending on the endianness of the platform. The LoadCollation call using a directory and the language ducet automatically select the correct file.

Classes and records

TCollationTablerecord
TCollationTableItemrecord
TUC_ProprecordUnicode character properties record.
TUCA_DataBookrecordCollation data book.
TUCA_PropItemContextRecrecordInternal structure for unicode collation data encoding.
TUCA_PropItemContextTreeNodeRecrecordInternal tree node structure for sorted storage of unicode collation data.
TUCA_PropItemContextTreeRecrecordInternal tree structure for sorted storage of unicode collation data.
TUCA_PropItemRecrecordUnicode Collation data item properties.
TUCA_PropWeightsrecordWeights.
TUInt24RecrecordUnicode integer 24-bit data.

Procedures and functions

AddAliasCollationfunction
BytesToNamefunction
BytesToStringfunction
CanonicalOrderprocedurePut unicode string in canonical order.
CompareSortKeyfunctionCompare two sort keys.
ComputeSortKeyfunctionCompute the sort key for a string.
FilterStringfunction
FindCollationfunctionFind a collation by name.
FreeCollationprocedureFree collation data.
FromUCS4procedureConvert UCS4 to UNicodeChar.
GetCollationCountfunctionReturn the number of known collations.
GetPropsfunctionGet unicode character data.
GetPropUCAfunctionGet unicode collation algorithm properties for a unicode character.
IncrementalCompareStringfunctionCompare 2 strings using the specified collation.
LoadCollationfunctionLoad a binary collation data file from file.
NormalizeNFDfunctionPerform unicode normalization D on a string.
PrepareCollationprocedurePrepare a collation for use in the list.
RegisterCollationfunctionRegister a new collation.
ToUCS4functionEncode unicode UTF16 surrogate pair to UCS4 character.
UnicodeIsHighSurrogatefunctionCheck if a UTF16 character is the high character in a surrogate pair.
UnicodeIsLowSurrogatefunctionCheck if a UTF16 character is the low character in a surrogate pair.
UnicodeIsSurrogatePairfunctionCheck if a pair of UTF16 encoded characters is a valid surrogate pair.
UnicodeToLowerfunctionTransform unicode string to lowercase.
UnicodeToUpperfunctionTransform unicode string to uppercase.
UnregisterCollationfunctionRemove a collation from the list of known collections.
UnregisterCollationsprocedureUnregister all collations.

Types

PCollationTableItemtype
PUC_ProptypePointer to TUC_Prop record.
PUCA_DataBooktypePointer to TUCA_DataBook type.
PUCA_PropItemContextRectypePointer to TUCA_PropItemContextRec.
PUCA_PropItemContextTreeNodeRectypePointer to TUCA_PropItemContextTreeNodeRec.
PUCA_PropItemContextTreeRectypePointer to TUCA_PropItemContextTreeRec.
PUCA_PropItemRectypePointer to TUCA_PropItemRec.
PUCA_PropWeightstypePointer to TUCA_PropWeights.
PUInt24typePointer to TUInt24Rec.
TCategoryMaskset
TCollationFieldenumerationOptions for the collation data.
TCollationFieldssetSet of TCollationField.
TCollationNametypeCollation name string type (fixed length).
TCollationTableItemArraytype
TCollationVersiontype
TEndianKindenumerationEndianness enumerator.
TSetOfByteset
TUCA_VariableKindenumerationOptions for weighting data.
TUCASortKeytypeArray of TUCASortKeyItem.
TUCASortKeyItemtypeAlias for WORD.
TUnicodeStringArraytype
UInt24typeAlias for TUInt24Rec.

Constants

DEFAULT_UCA_COMPARISON_STRENGTHconstant
DirectorySeparatorconstant
ENDIAN_SUFFIXconstantSuffixes for endianness.
ERROR_INVALID_CODEPOINT_SEQUENCEconstantError exit code for UnicodeToLower/UnicodeToUpper.
HIGH_SURROGATE_BEGINconstantFirst value for high surrogate values.
HIGH_SURROGATE_COUNTconstantNumber of high surrogate values.
HIGH_SURROGATE_ENDconstantLast value for high surrogate values.
LOW_SURROGATE_BEGINconstantFirst value for low surrogate values.
LOW_SURROGATE_ENDconstantLast value for low surrogate values.
MAX_LEGAL_UTF32constantMaximum value of a legally encoded UTF32 value (currently unused).
MAX_WORDconstantMaximum value of a WORD typed value.
reCodesetConversionconstant
ROOT_COLLATION_NAMEconstantName of the root collation (used if no collation name is given).
UCS4_HALF_BASEconstantOffset for UCS4 character encoding.
UCS4_HALF_MASKconstantUnused currently.
UGC_ClosePunctuationconstantUnicode token category: Close punctuation.
UGC_CombiningMarkconstantUnicode token category: Uppercase letter.
UGC_ConnectPunctuationconstantUnicode token category: Connect punctuation.
UGC_ControlconstantUnicode token category: control token.
UGC_CurrencySymbolconstantUnicode token category: Currency symbol.
UGC_DashPunctuationconstantUnicode token category: Dash punctuation.
UGC_DecimalNumberconstantUnicode token category: Uppercase letter.
UGC_EnclosingMarkconstantUnicode token category: Uppercase letter.
UGC_FinalPunctuationconstantUnicode token category: Final punctuation.
UGC_FormatconstantUnicode token category: Formatting token.
UGC_InitialPunctuationconstantUnicode token category: Initial punctuation.
UGC_LetterNumberconstantUnicode token category: Letter-number.
UGC_LineSeparatorconstantUnicode token category: Line separator.
UGC_LowercaseLetterconstantUnicode general category: Lowercase letter.
UGC_MathSymbolconstantUnicode token category: Math symbol.
UGC_ModifierLetterconstantUnicode general category: modifier letter.
UGC_ModifierSymbolconstantUnicode token category: modifier symbol.
UGC_NonSpacingMarkconstantUnicode general category: Non-spacing mark.
UGC_OpenPunctuationconstantUnicode token category: Open punctuation.
UGC_OtherLetterconstantUnicode general category: Other letter.
UGC_OtherNumberconstantUnicode token category: Other number.
UGC_OtherPunctuationconstantUnicode token category: Other punctuation.
UGC_OtherSymbolconstantUnicode token category: Other symbol.
UGC_ParagraphSeparatorconstantUnicode token category: Paragraph separator.
UGC_PrivateUseconstantUnicode token category: For private use.
UGC_SpaceSeparatorconstantUnicode token category: Space separator.
UGC_SurrogateconstantUnicode token category: Surrogate token.
UGC_TitlecaseLetterconstantUnicode general category: Titlecase letter.
UGC_UnassignedconstantUnicode token category: As yet unassigned.
UGC_UppercaseLetterconstantUnicode general category: Uppercase letter.
UnicodeCategoryNamesconstant
ZERO_UINT24constantEmpty TUInt24Rec value.

Resource strings

SCollationNotFoundresource stringError message when a collation is not found.

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