Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining characters using their hexa name

Tags:

unicode

raku

This works:

say "\c[COMBINING BREVE, COMBINING DOT ABOVE]"  # OUTPUT: «̆̇␤»  

However, this does not:

say "\c[0306, 0307]"; # OUTPUT: «IJij␤»

It's treating it as two different characters. Is there a way to make it work directly by using the numbers, other than use uniname to convert it to names?

like image 530
jjmerelo Avatar asked Apr 22 '19 16:04

jjmerelo


2 Answers

The \c[…] escape is for declaring a character by its name or an alias.
0306 is not a name, it is the ordinal/codepoint of a character.

The \x[…] escape is for declaring a character by its hexadecimal ordinal.

say "\x[0306, 0307]"; # OUTPUT: «̆̇␤»

(Hint: There is an x in a hexadecimal literal 0x0306)

like image 109
Brad Gilbert Avatar answered Sep 22 '22 21:09

Brad Gilbert


\c uses decimal numbers:

say "\c[774, 775]"

where 774 is the decimal equivalent of 0306, works perfectly.

like image 39
jjmerelo Avatar answered Sep 23 '22 21:09

jjmerelo