Difference between revisions of "UnicodeString"

From Lazarus wiki
Jump to navigationJump to search
(English translation of German page)
 
(Conversion Utf8<->Utf16 is in LazUtf8 unit, not in LCLProc)
Line 9: Line 9:
 
A [[Data field|data field]] of the data type '''UnicodeString''' has no size restriction and consists internally of an array of the [[Unicodechar|UniCodeChar]] data type.
 
A [[Data field|data field]] of the data type '''UnicodeString''' has no size restriction and consists internally of an array of the [[Unicodechar|UniCodeChar]] data type.
  
The functions of the [[LCLProc]] unit are required for problem-free type conversion from [[Ansistring|AnsiString]] to UnicodeString and from UnicodeString to AnsiString.
+
The functions of the LazUtf8 unit are required for problem-free type conversion from [[Ansistring|AnsiString]] to UnicodeString and from UnicodeString to AnsiString.
  
 
Unicode strings are used to display strings from the Unicode character set. Unicode strings are implemented in the same way as AnsiStrings and can be cast (converted) to the [[Punicodechar|PUnicodeChar]] data type.
 
Unicode strings are used to display strings from the Unicode character set. Unicode strings are implemented in the same way as AnsiStrings and can be cast (converted) to the [[Punicodechar|PUnicodeChar]] data type.

Revision as of 23:58, 17 December 2023

English (en)


Back to data types.

Back to Character and string types.


A data field of the data type UnicodeString has no size restriction and consists internally of an array of the UniCodeChar data type.

The functions of the LazUtf8 unit are required for problem-free type conversion from AnsiString to UnicodeString and from UnicodeString to AnsiString.

Unicode strings are used to display strings from the Unicode character set. Unicode strings are implemented in the same way as AnsiStrings and can be cast (converted) to the PUnicodeChar data type.

Definition of a data field of data type UnicodeString:

var 
  u : UnicodeString;
  a : AnsiString;

The examples below apply to the Windows operating system!

Examples for the valid assignment of AnsiString to WideString:

  u := UTF8ToUTF16('0123ABCabc456AöU!, .-');
  u := u + UTF8ToUTF16(IntToString(45));

Example of the valid assignment of WideString to AnsiString:

  a := UTF16ToUTF8(u);