JSONを非同期に取得するためにAFNetworkingを使用しようとしています。
UTF8でエンコードされたjsonファイルがあり、AFJSONRequestOperationがUTF8コードで辞書を返します。
éphémère --> \U00c3\U00a9ph\U00c3\U00a9m\U00c3\U00a8re
UTF8をAFJSONRequestOperationでうまく機能させる方法はありますか?
AFJSONRequestOperationを使用する2番目の問題があります:彼はBOMでUTF8ファイルを読み取ることができません。
これが私のコードです:
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/plain"]];
AFJSONRequestOperation *operation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON)
{
NSLog(@"JSON: %@", JSON);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON)
{
NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);
}];
[operation start];
その前はJSONKitを使用していましたが、うまく機能します(charset + BOM)!しかし、非同期呼び出しを行う必要があります。
ご協力ありがとうございました!