* * *

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

440bx

  • Sr. Member
  • ****
  • Posts: 336
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: 7136
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.
inline variables like in D10.3 are a bit like Brexit: if you are given the wrong information it sounds like a good idea. Every kid loves candy, but it makes you fat and your teeth will disappear.

440bx

  • Sr. Member
  • ****
  • Posts: 336
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