yax
yax

Reputation: 133

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. I get a strange question mark symbol inside a black shape [�C].

To parse JSON i use this method:

    if let data = dataToParse{
        do {
            parsedConfigurationObject = try NSJSONSerialization.JSONObjectWithData(data, options:NSJSONReadingOptions.MutableContainers) as! NSDictionary
        }catch{

        }
    }else{

    }

Any help? Thanks

Upvotes: 1

Views: 628

Answers (1)

Alessandro Ornano
Alessandro Ornano

Reputation: 35392

I'm not sure about your UTF8 Json. Have you try to encoding your data with UTF8?

extension String {
    func utf8() -> NSData? { return (self as NSString).dataUsingEncoding(NSUTF8StringEncoding) }
}

Use:

"{}".utf8()

Upvotes: 2

Related Questions