Recent

Author Topic: can writeln output null terminated wide character arrays ?  (Read 774 times)

440bx

  • Sr. Member
  • ****
  • Posts: 487
can writeln output null terminated wide character arrays ?
« on: July 09, 2018, 04:45:48 am »
Hello,

The following works fine

Code: Pascal  [Select]
  1. var
  2.    anarrowstring : pchar = 'this is a "narrow" string';
  3. ...
  4. begin
  5.    writeln(anarrowstring);
  6. end.
  7.  
The compiler is, as expected, perfectly happy with that.  On the other hand, if pchar is changed to pwidechar, the compiler emits an error stating that variables of that type can neither be read nor written.  e,g.  the following does not work :


Code: Pascal  [Select]
  1. var
  2.    awidestring : pwidechar = 'this is a "wide" string';
  3. ...
  4. begin
  5.    writeln(awidestring);
  6. end.
  7.  

Did I miss something or is it really the case that writeln cannot write wide characters to the console ?   I can always import wprintf from user32.dll but, I'd rather keep things "pascal" if possible.

Thank you for your help.


Thaddy

  • Hero Member
  • *****
  • Posts: 7420
Re: can writeln output null terminated wide character arrays ?
« Reply #1 on: July 09, 2018, 07:05:09 am »
Cast to unicodestring?

Code: Pascal  [Select]
  1. program untitled;
  2. var
  3.    awidestring : pwidechar = 'this is a "wide" string';
  4.  
  5. begin
  6.    writeln(unicodestring(awidestring));
  7. end.
Ad Brexinitum (can't help it)

440bx

  • Sr. Member
  • ****
  • Posts: 487
Re: can writeln output null terminated wide character arrays ?
« Reply #2 on: July 09, 2018, 06:19:44 pm »
That works :D.  Thank you Thaddy.