简体   繁体   English

Unicode字符的Swift String文字错误

[英]Swift String literal for unicode character is wrong

I am trying to pass a unicode character from Swift to a UIWebPage. 我试图将Swift的unicode字符传递给UIWebPage。 The String is coming in from the server as "\\\\2020" so that the escaped version should be "\\2020" (the dagger symbol). 服务器将字符串作为"\\\\2020"从服务器"\\\\2020" ,因此转义版本应为"\\2020" (匕首符号)。 When it is passed in however, it is becoming "2020" . 但是,当它通过时,它将变成"2020" Is it breaking in the javascript or before it gets there? 是打破了JavaScript还是到达了JavaScript?

要在Swift中表示角色,您必须使用这种插值方式:

let dagger = "\u{2020}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM