Copies a null terminated WideChar string to a normal string System unit
 function WideCharToString(Source PWideChar;):string;
The WideCharToString function converts a null terminated WideChar string or array to a normal string.
WideChar's are 2 bytes in size, to accomodate International character sets, such as Chinese, where the number of characters exceeds 256.
Such a double byte to single byte conversion will preserve the double byte size when it cannot be mapped to a single byte. So a 10 character WideChar string will yield anything from 10 to 20 characters in the resulting string.
Related commands
StringToWideCharConverts a normal string into a WideChar 0 terminated buffer
 Download this web site as a Windows program.

Example code : A simple example
  wideCharArray : array[0..5] of WideChar;
  myString      : String;

  // Set up our WideChar array
  wideCharArray[0] := 'H';
  wideCharArray[1] := 'e';
  wideCharArray[2] := 'l';
  wideCharArray[3] := 'l';
  wideCharArray[4] := 'o';
  wideCharArray[5] := #0;  // Terminates WideChar strings

  // Copy to a normal string
  myString := WideCharToString(wideCharArray);

  // Show what the copy gave
Show full unit code
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page