I am trying to convert the U+XXX code to the Unicode byte representation and put it using Text_IO.
Using Wide_Wide_Character’Val (16#EEAB9A#) doesn’t display the character properly:
with Ada.Wide_Wide_Text_IO;
with Ada.Wide_Wide_Characters;
declare
Symbol : Wide_Wide_Character := Wide_Wide_Character'Val (16#EEAB9A#);
begin
Ada.Wide_Wide_Text_IO.Put (Symbol);
end
If I use the character literal in the source file I get the error:
error: (Ada 2005) non-graphic character not permitted in character literal
Your code certainly works with 16#1E2# (Ǣ), and the unicode converters I’ve checked with on the net don’t give a result for your number. As a colour value, it’s Sea Pink
Eureka! I was converting the values on the nerdfonts website using the UTF conversion template erroneously, this is not necessary. Just add the value into the symbol and print.
with Ada.Wide_Wide_Characters; use Ada.Wide_Wide_Characters;
with Ada.Wide_Wide_Text_IO;
declare
Symbol : Wide_Wide_Character : Wide_Wide_Character'Val (16#ec19#);
begin
Ada.Wide_Wide_Text_IO.Put (Symbol);
end;
OK, I have no idea why are you keep on trying to output illegal code points. None of the numbers you specified are legal Unicode code points.
Anyway, using Wide_Wide_Text_IO is highly non-portable. Windows console simply does not support UTF-32. It says that it does, the code page 12000, but it does not on my machine. Nether does Windows support UTF-16, which would be Wide_Text_IO. Which is a bit strange because internally Windows is UTF-16.
Wide_Wide_Text_IO is wasting resources too.
The most compatible encoding is UTF-8 which works both under Linux and Windows (chcp 65001).
with Ada.Text_IO;
with Strings_Edit.UTF8; use Strings_Edit.UTF8;
procedure Test is
begin
Ada.Text_IO.Put_Line ("hello I am a block " & Image (16#25A1#));
end Test;
Function Image converts a code point into UTF-8 encoded string.
I don’t think nerd_type is trying to print the code points themselves, just the numeric position of the code points (So 0030 instead of '0' (which is U+0030)). For that, it doesn’t make much difference if they are illegal or or not, in a practical sense.