Michel
Michel

Reputation: 11749

Unicode & Circled numbers in Swift

Looking at circled numbers, Unicode and experimenting I found out that I could print this character in swift using this code:

print("N:\u{325B}:") // Prints N:㉛:

I would like to print it the following way (or similar), that is put the value 0x325B in a variable before feeding it to print, but that does not work:

let v = 0x325B
print(“N:\u{\(v)}:”) // Prints N:㉛:

Does anyone know how to do what I want?

Upvotes: 0

Views: 328

Answers (1)

vacawama
vacawama

Reputation: 154691

Use UnicodeScalar to convert your Int value to your Character:

let v = 0x325B
print("N:\(UnicodeScalar(v)):") // prints N:㉛:

Upvotes: 2

Related Questions