Hey, my drawback is that this:
From a lexer I obtain a string containing the worth of a personality literal, for instance:
'A'
'B'
'+'
'n'
From these strings I need to receive its corresponding UNICODE code, since it’s a string, the very first thing I do is trim the string with the character (single quote) "'"
, so I get the next strings
A
B
+
n
From the above strings I wish to get the UNICODE code worth and retailer it, what I’ve tried is the next:
trimmedValue := strings.Trim(charLiteral, "'")
chars := []rune(trimmedValue)
From right here I can get the worth for the primary three circumstances, 65
, 66
, 43
however easy methods to convert the string n to its unicode worth, since on this approach I get a slice of two totally different values, that’s, easy methods to make n be interpreted as a solely worth/character? Is there a direct approach to do it?
Thanks
FWIW: That provides you the ASCII worth AFAIK.
You might have considered trying to check out: string – How can I get the Unicode worth of a personality in go? – Stack Overflow