Unicode character description escapes

51 Views Asked by At

I'm revisiting a browser add-on I created quite a while ago which offered conversion to and from various Unicode escape sequences.

However, I have now quite absentmindedly forgotten, and been unable to rediscover, mention of the language where an escape sequence like \C{Latin Small Letter A} was supposed to work (a Unicode description being substituted by the actual Unicode character, in this case, "a").

I believe it was in PHP, or perhaps at least a proposal for PHP, but I do not see any specs which support this syntax now.

1

There are 1 best solutions below

0
cetver On

PHP can only work with a codepoint

$ php -r 'var_dump("\u{2615}");'
string(3) "☕"

Python can

>>> import unicodedata

>>> print(unicodedata.lookup('Hot Beverage'))
☕

You can use a Python script and call it from the PHP