[英]Swift : Wrong character in String
i'm parsing a UTF8 Json, and i don't understand why the degree symbol "°" is wrong when i try to show it in a UILabel. 我正在解析UTF8 Json,并且当我尝试在UILabel中显示度数符号“°”时,我不明白为什么它是错误的。 I get a strange question mark symbol inside a black shape [ C].
我在黑色[C]内收到一个奇怪的问号符号。
To parse JSON i use this method: 要解析JSON,请使用以下方法:
if let data = dataToParse{
do {
parsedConfigurationObject = try NSJSONSerialization.JSONObjectWithData(data, options:NSJSONReadingOptions.MutableContainers) as! NSDictionary
}catch{
}
}else{
}
Any help? 有什么帮助吗? Thanks
谢谢
I'm not sure about your UTF8 Json. 我不确定您的UTF8 Json。 Have you try to encoding your data with UTF8?
您是否尝试过使用UTF8编码数据?
extension String {
func utf8() -> NSData? { return (self as NSString).dataUsingEncoding(NSUTF8StringEncoding) }
}
Use: 采用:
"{}".utf8()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.