I want to decode response from the http request. But getting error while encoding to .utf8
String(data: data, encoding: .utf8)
returns nil
when data contains umlauts from German language(Ü Ö Ä ü ö ä è é)
How can I decode the Data?
object properly?
Edit: Providing more details
This is how my response looks like. I can't change it's coming from backend similar to this.
let string = """
{
"test":"Value",
"OperatingInfosQuotes":"\n<div id=\"div_operatinginfo_inner\">\n<div id=\"div_operatinginfo_title\"><b>Test</b></div>\n<div id=\"div_operatinginfo_content\">\n\n Ü Ö Ä ü ö ä è é\n\n</div>\n</div>\n"
}
"""
do {
let encode = try JSONDecoder().decode(TestObject.self, from: Data(string.utf8))
print(encode)
} catch {
print("Count not decode")
}
And my codable object:
struct TestObject: Codable {
var test: String
}
How can I handle it?