String representation of hexadecimal to unicode character

Is there a builtin function to transform the string representation of an hexadecimal to the corresponding unicode character?

# we can for example do
julia> Char(0x03C0)
'π': Unicode U+03c0 (category Ll: Letter, lowercase)
# but what if we want to go from string to character ?
julia> Char(xxx("03C0"))
'π': Unicode U+03c0 (category Ll: Letter, lowercase)

what would be the function xxx above?

xxx == parse:

julia> Char(parse(UInt32, "03C0", base=16))
'π': Unicode U+03C0 (category Ll: Letter, lowercase)
4 Likes

Thanks!

I still do not get why this is case insensitive:

# uppercase
julia> Char(parse(UInt32, "03C0", base=16))
'π': Unicode U+03c0 (category Ll: Letter, lowercase)
# lowercase
julia> Char(parse(UInt32, "03c0", base=16))
'π': Unicode U+03c0 (category Ll: Letter, lowercase)

Hexadecimal parsing in Julia is case-insensitive everywhere (you can also type 0x03C0 instead of 0x03c0, for example). Why would you want case-sensitive behavior?

2 Likes

I was expecting case-sensitiveness because I was thinking about the reverse transformation of:

julia> convert(Int,'A')
65
julia> convert(Int,'a')
97

but now it’s clear it isn’t the same :slight_smile: