0
如何在AFNetworking iOS中編碼/設置UTF-8非英文字符(例如中文字符我)以請求?如何在AFNetworking iOS中傳遞非英文字符以請求?
我的代碼:
NSMutableSet *contentTypes = [[NSMutableSet alloc] initWithSet:self.httpManager.responseSerializer.acceptableContentTypes];
[contentTypes addObject:@"text/plain"];
[contentTypes addObject:@"text/html"];
[contentTypes addObject:@"application/x-www-form-urlencoded"];
[contentTypes addObject:@"charset=UTF-8"];
[contentTypes addObject:@"application/json"];
self.httpManager.responseSerializer.acceptableContentTypes =
[NSSet setWithArray:@[@"text/plain",
@"text/html",
@"application/x-www-form-urlencoded",
@"charset=UTF-8",
@"application/json"]];
後端會得到這樣的事情
阿拉伯原子能機構
,而不是正確的字符。
這是否意味着你的後端與比UTF-8別的什麼解碼? – Pochi
@Pochi我不確定,因爲我無法觸摸後端代碼,但它適用於Android應用程序。 – Rendy
@Rendy當您嘗試在Postman中調用服務時,您是否獲得了相同的數據? – Nirmalsinh