Skip to content

Charinfo fails to link newline characters (and several others) #2611

@bast0006

Description

@bast0006

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: frontendRelated to output and formattinga: utilityRelated to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils)help wantedExtra attention is neededl: 1 - intermediatep: 3 - lowLow Priorityt: bugSomething isn't workingt: enhancementChanges or improvements to existing features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions