DelphiBasics
PWideChar
Type
Pointer to a WideChar System unit
PWideChar = ^WideChar;
Description
The PWideChar type holds a pointer to a WideChar value.
 
It can also be used to point to characters within a WideString, as in the example code.
 
As with other pointers, integer arithmetic, such as Inc and Dec can be performed on a PWideChar variable, also shown in the example.
Notes
PWideChar is principally used when processing null-terminated (C-like) strings.
Related commands
$ExtendedSyntaxControls some Pascal extension handling
DecDecrement an ordinal variable
IncIncrement an ordinal variable
PAnsiCharA pointer to an AnsiChar value
PCharA pointer to an Char value
PWideStringPointer to a WideString value
WideCharVariable type holding a single International character
WideStringA data type that holds a string of WideChars
 Download this web site as a Windows program.




 
Example code : Display all characters in a string
var
  myWideString  : WideString;
  myWideCharPtr : PWideChar;
  i : Integer;

begin
  // Create a string of WideChar's
  myWideString  := 'Hello';

  // Point to the first character in the string
  myWideCharPtr := Addr(myWideString[1]);

  // Display the string
  ShowMessage(myWideCharPtr);

  // Now increment the pointer
  Inc(myWideCharPtr,2);

  // And see what is shows now
  ShowMessage(myWideCharPtr);

  // Display all characters in the string
  while i <= Length(myWideString) do
  begin
    ShowMessage(myWideCharPtr^);
    Inc(i);
    Inc(myWIdeCharPtr);
  end;
end;
Show full unit code
  Hello
  llo
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page