Recent

Author Topic: Unicode chr()  (Read 531 times)

domasz

  • Hero Member
  • *****
  • Posts: 541
Unicode chr()
« on: August 09, 2024, 11:55:35 am »
Hello,
I have UTF-16 codes for characters. I need to convert them to Unicode string and display in TMemo.
Code: Pascal  [Select][+][-]
  1. type
  2.  
  3.     Tutf16conv=record
  4.     case byte of
  5.     0:(C:UnicodeChar);
  6.     1:(W:word);
  7.     end;
  8.  
  9. var     Body: UnicodeString;
  10.     ch: Tutf16conv;
  11. Buf: array of Byte;
  12.  
  13. begin
  14.   Body := '';
  15.  
  16.   for i:=0 to Size-1 do begin
  17.     ch.W := Buf[i] + 57344;
  18.  
  19.     Body := Body + ch.C;
  20.   end;
  21.  
  22. Memo1.Lines.Text :=  Body;
  23.  

This just produces rubbish.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11780
  • FPC developer.
Re: Unicode chr()
« Reply #1 on: August 09, 2024, 12:07:04 pm »
$E000/57344 is private use area ( https://en.wikipedia.org/wiki/Private_Use_Areas)

So the font probably has no characters mapped there. So at first glance the code doesn't make sense.

You need to explain what you actually expect and why.

domasz

  • Hero Member
  • *****
  • Posts: 541
Re: Unicode chr()
« Reply #2 on: August 09, 2024, 12:13:09 pm »
I want to display ATASCII file using this font:
http://members.bitstream.net/marksim/atarimac/fonts.html

Code: Pascal  [Select][+][-]
  1. The original Atari characters are located in the Unicode "private use area", starting at location $E000.
  2.  

domasz

  • Hero Member
  • *****
  • Posts: 541
Re: Unicode chr()
« Reply #3 on: August 09, 2024, 12:21:17 pm »
It actually does work but font needs to be set differently.

"good.png" shows how I have to choose font. "bad.png" invokes a popup that doesn't have all the fonts and charset cannot be changed to unicode.

MarkMLl

  • Hero Member
  • *****
  • Posts: 7711
Re: Unicode chr()
« Reply #4 on: August 09, 2024, 01:38:46 pm »
That obviously depends on the OS being used, and on the extent to which the OS (including the frontend GUI etc.) is capable of handling whatever font file the website is making available.

Quite frankly, I'd start with something like FontForge and work from there.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018