[fpc-pascal] Printing unicode characters

James Richters james.richters at productionautomation.net
Sun Dec 1 17:19:29 CET 2024


Indeed you CAN print Unicode characters, but not with the normal windows command prompt, nor with powershell, that is where the problem is, not with FreePascal.  But if you go to the Windows Store and download the free “Windows Terminal” there you can get it to work.
 
When you run the windows terminal, you get a powershell window, and ‘+’ gets you a new powershell window, but you can push the little down arrow next to the + and get a Command Prompt… there is a way to make the command prompt the default in the settings.  
 
If you run your pascal program inside the command prompt window of Windows terminal, you will find that you get full color Unicode characters.


I just tested it on Windows 10 and the following work:
   Writeln('Unicode scalar 1F496: ', #$1F496); // 💖
   Writeln('Unicode scalar 1F496: 💖');  //

This one does not work:
   Writeln('Unicode scalar 1F496: ', WideChar($1F496));  // 💖
 
Note that these only work if you do NOT use the CRT unit.

James
 
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of Hairy Pixels via fpc-pascal
Sent: Sunday, December 1, 2024 1:14 AM
To: FPC-Pascal discussions <fpc-pascal at lists.freepascal.org>
Cc: Hairy Pixels <genericptr at gmail.com>
Subject: [fpc-pascal] Printing unicode characters
 
ChatGPT is saying I can  print unicode scalars like that but i don’t see it works and no compiler warnings even. Did it make this up or did I do something wrong?
 
  Writeln('Unicode scalar 1F496: ', #$1F496); // 💖
  Writeln('Unicode scalar 1F496: ', WideChar($1F496));  // 💖


Regards,
    Ryan Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20241201/73a1013f/attachment-0001.htm>


More information about the fpc-pascal mailing list