Matteo Serpentoni Matteo Serpentoni - 7 months ago 54
iOS Question

Unable to convert data to string around character

i'm trying to do an HTTP-Get request to get users on my database. After the data return from the request i use SwiftyJson library to get the users.

But, one of the users in his name contains the character "ò" and i received this error:

Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Unable to convert data to string around character 208."
UserInfo={NSDebugDescription=Unable to convert data to string around character 208.})

Here is my code:

func makeHTTPGetRequest(path: String, onCompletion: ServiceResponse) {
let request = NSMutableURLRequest(URL: NSURL(string: path)!)
let session = NSURLSession.sharedSession()
let task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
if let jsonData = data {
var parseError: NSError?
let json:JSON = JSON(data: jsonData, error: &parseError)
onCompletion(json, parseError)
} else {
onCompletion(nil, error)


If i understood the problem, i think that you have to set the output of your servlet to UTF-8. An example, if you use a Java Servlet you can use