* * *

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

440bx

  • Jr. Member
  • **
  • Posts: 60
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: 6374
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.
I am enjoining wine, not whine....

440bx

  • Jr. Member
  • **
  • Posts: 60
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.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus