[fpc-pascal]Wide strings

Gabor DEAK JAHN djg at argus.vki.bke.hu
Mon Dec 25 11:34:07 CET 2000


Quite a few Win32 functions and procedures require wide (Unicode) strings as 
arguments (simple ones come in two flavors, both ANSI and Unicode, but 
sophisticated ones like those connected to COM and OLE are Unicode-only). 
These strings are, from the programmer's point of view, similar to PChars 
but the individual characters are two bytes long). There is a function to 
convert between the two formats, however, when the string in question is 
constant, this is rather uncomfortable.

LCC (a free C compiler) uses the following notation (note the L right before 
the literal):

  char *MethodID = L"ViewCopyEditor"

However, in FPC I found no better way than to write:

  MethodID : PChar =

which is, although technically equivalent, rather clumsy. The cleanest 
solution would probably be to introduce a new simple type, widechar, which 
occupies 2 bytes and, unlike word, does accept a typed-constant 
initialization like PChar does:

  PWideChar = ^widechar;
  MethodID : PWideChar = 'ViewCopyEditor';


   Gabor DEAK JAHN

Gabor DEAK JAHN -- Budapest, Hungary.
WWW: <http://www.tramontana.co.hu/>www.tramontana.co.hu
E-mail: djg at tramontana.co.hu

More information about the fpc-pascal mailing list