Charinfo fails to link newline characters (and several others) #2611
Labels
a: frontend
Related to output and formatting
a: utility
Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils)
help wanted
Extra attention is needed
l: 1 - intermediate
p: 3 - low
Low Priority
t: bug
Something isn't working
t: enhancement
Changes or improvements to existing features
Currently, the !charinfo command runs
unicodedata.name()
to figure out what name a character should be given. However,unicodedata.name()
does not support control characters like the newline characters such as \n, the null character, or a variety of other ones that have unicode names as aliases but not official "recognized" names which are often "" for some reason.There's an open bug on cpython for a few years now, but it doesn't look like there's much activity (python/cpython#71683)
Unfortunately it doesn't look like there's an easy standard library hack either (please correct me if I'm wrong!) because
unicodedata
is generated C, then compiled, and the only interface to the data is through lookup functions (and we'd want to go the other direction, from character to aliases). I've also had no luck in looking at additional libraries, so any actual solution to this might just fall down to a hardcoded list.At the very least, we should consider "cleaning up" the output so that instead of injecting empty space we use the character id perhaps like
\0x0a
, for newline, for the link name so it doesn't visually break?(ex: https://discord.com/channels/267624335836053506/635950537262759947/1111690082441769011)
The text was updated successfully, but these errors were encountered: