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?
Asked
Active
Viewed 1,397 times
6

Lee Probert
- 10,308
- 8
- 43
- 70
1 Answers
8
To represent the character in Swift you must use this kind of interpolation:
let dagger = "\u{2020}"

Eric Aya
- 69,473
- 35
- 181
- 253
-
So, can I do this: if let codeStr:String = String(m.bullet!.characters.dropFirst()){ let unicodeStr:String = "\\u{\(codeStr)}" } – Lee Probert May 09 '16 at 09:44
-
1@LeeProbert, see this answer if you have `"2020"` in a `String var` and want to convert it: http://stackoverflow.com/a/32555223/1630618 – vacawama May 09 '16 at 09:57