ObjectPascal
WideString
Type
A data type that holds a string of WideChars System unit
  type WideString;
Description
The WideString data type is used to hold sequences of International characters, like sentences.
 
Each character is a WideChar, guaranteed to be 16 bits in size.
 
WideChar types provide support for multi-byte International character sets such as Chinese, which have vast numbers of characters (idiograms) in their character sets.
 
Unlike ShortStrings, WideStrings are pointer referenced variables (for Windows - for Linux, they are not). Storage is allocated for an AnsiString only when needed. For example, assigning the value of one AnsiString to another does not allocate storage for a copy of the first string. Instead, the reference count of the first string is incremented, and the second AnsiString set to point to it.
 
But when the second string is changed, new storage is obtained for this new string, and the reference count for the first string is decremented.
 
When a string is no longer referenced (the last AnsiString referer is set to nil), it is discarded. This is an example of Delphi managing storage on your behalf.
 
WideStrings can be assigned from other strings, from functions that return a string, and with concatenations as in the sample code.
 
When assigning to a 'narrow' string, such as an AnsiString, the double to single byte conversion can have unpredictable results. Use with care.
 
Converting from AnsiString to WideString is trouble free.
Notes
Strings are indexed with 1 for the first character (arrays start with 0 for the first element).
Related commands
AnsiCompareStr Compare two strings for equality
AnsiLowerCase Change upper case characters in a string to lower case
AnsiPos Find the position of one string in another
AnsiUpperCase Change lower case characters in a string to upper case
Concat Concatenates one or more strings into one string
Copy Create a copy of part of a string or an array
Delete Delete a section of characters from a string
Length Return the number of elements in an array or string
Move Copy bytes of data from a source to a destination
PWideString Pointer to a WideString value
SetLength Changes the size of a string, or the size(s) of an array
String A data type that holds a string of characters
WideChar Variable type holding a single International character
 
Example code : Assign to two WideStrings and manipulate these
var
  string1, string2 : WideString;
begin
  // Assign a famous sentence to the first string
  string1 := 'Hello World';

  // Assign to the second string
  // This simply points string2 at string1
  // The 'Hello World' string storage has a reference count of 2
  string2 := string1;

  // Add to the second string
  // This disassociates from string1 - new string storage is
  // created to hold the string2 value
  string2 := string2 + ', how is everyone?';

  // And finally, set the length of the first string to 5
  SetLength(string1, 5);

  // Display both strings
  WriteLn('String1 = '+string1);
  WriteLn('String2 = '+string2);
end;
Show full unit code
   String1 = Hello
   String2 = Hello World, how is everyone?