Skip to content

Format the hex codes in Unicode/hex escape sequences (\U, \u, \x) in string literals #2067

@Jackenmen

Description

@Jackenmen

Is your feature request related to a problem? Please describe.
Currently, one can write either "\U0001f977" or "\U0001F977" which are equivalent but they look differently. Similarly, one can write "\u200b" or "\u200B" which also are equivalent but they look differently (do mind that \U and \u are NOT equivalent though; unless we also want to talk about shortening "\U0000200b" to "\u200b" which I guess would make sense but is probably a separate issue).

Right now, I'm forced to think whether I should use uppercase or lowercase letters as Black doesn't enforce it.

Describe the solution you'd like
I think it would make sense to have these be consistent in some way, possibly in the same way as the numeric literals, although personally, I think it would make more sense to have it all uppercase in case of \U0001F977 and all lowercase in case of \u200b. I definitely think that the \u200b should not be \u200B but I don't have a strong opinion on the \U0001f977 vs \U0001F977.

Describe alternatives you've considered
Alternatives were not considered.

Additional context
None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: stringsRelated to our handling of stringsT: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions