Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1216

How to decode a string from Instagram backup in Swift?

$
0
0

This is a part of my Instagram account backup

[  {"media": [      {"title": "\u00d0\u0094\u00d0\u00be\u00d1\u0080\u00d0\u00be\u00d0\u00b3\u00d0\u00be\u00d0\u00b9 \u00d0\u00b4\u00d1\u0080\u00d1\u0083\u00d0\u00b3"      }    ]  }]

To parse this I use Codable

struct BlogPost: Codable {    let media: [Media]}struct Media: Codable {    let title: String}

But this code prints ÐоÑогойдÑÑг

let bundle = Bundle.mainlet path = bundle.path(forResource: "posts_1", ofType: "json")let content = try? String(contentsOfFile: path!)let data = content!.data(using: .utf8)!let result = try? JSONDecoder().decode([BlogPost].self, from: data)print(result![0].media[0].title)

And it should print Дорогойдруг. How to decode this string on iOS? I am also using mothereff.in to decode backup data.


Viewing all articles
Browse latest Browse all 1216

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>