Skip to content

Function to get Unicode code point notation like U+0061 #54683

Open

Description

I sometimes want to use a function to get Unicode code point notation used in convention like U+0061 (Unicode 15.0, p.968) from Char. Such function is implemented in

julia/base/char.jl

Lines 331 to 339 in f942c29

if isoverlong(c)
print(io, "[overlong] ")
u = decode_overlong(c)
c = T(u)
else
u = codepoint(c)
end
h = uppercase(string(u, base = 16, pad = 4))
print(io, (isascii(c) ? "ASCII/" : ""), "Unicode U+", h)

and it is easy to write:

unicode_code_point_notation(c::AbstractChar) = "U+" * uppercase(string(codepoint(c), base=16, pad=4))

But I think it is good to have the function in module Unicode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    unicodeRelated to unicode characters and encodings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions