utf 8 - How can I get the Unicode codepoint represented by an integer in Swift? -
so know how convert string utf8 format
for character in strings.utf8 { // example converted 65 var utf8value = character }
i read guide can't find how convert unicode code point represented integer string. example: converting 65 a. tried use "\u"+utf8value still failed.
is there way this?
if @ enum definition character
can see following initializer:
init(_ scalar: unicodescalar)
if @ struct unicodescalar, see initializer:
init(_ v: uint32)
we can put them together, , whole character
character(unicodescalar(65))
and if want in string, it's initializer away...
1> string(character(unicodescalar(65))) $r1: string = "a"
or (although can't figure out why 1 works) can do
string(unicodescalar(65))
Comments
Post a Comment