Lee Probert
Lee Probert

Reputation: 10859

Swift String literal for unicode character is wrong

I am trying to pass a unicode character from Swift to a UIWebPage. The String is coming in from the server as "\\2020" so that the escaped version should be "\2020" (the dagger symbol). When it is passed in however, it is becoming "2020". Is it breaking in the javascript or before it gets there?

Upvotes: 6

Views: 1643

Answers (1)

Eric Aya
Eric Aya

Reputation: 70098

To represent the character in Swift you must use this kind of interpolation:

let dagger = "\u{2020}"

Upvotes: 8

Related Questions