0

I am stuck with problem in iOS chat app where we are reading response from webservice as JSON. In Android chat is working fine but not able to succeed in iOS chat app.

In my SQL db we have tried all four character sets available (sjis_japanese_ci).

In iOS, we are expecting response from server in NSUTF8Encoding but the encoding suggested by iOS API is NSWindowsCP1251StringEncoding and we try to use that encoding then decoded string has corrupted Japanese data.

API method we are using to detact the encoding is

NSStringEncoding encoding = [NSString stringEncodingForData:aResponseData encodingOptions:nil convertedString:nil usedLossyConversion:NO];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
anil kumar
  • 89
  • 3
  • 8
  • Show the code you are using to try this out – Diogo Antunes Sep 06 '16 at 14:04
  • Why do you need to detect anything or use multiple encodings? Just manipulate strings as UTF-8 everywhere, and you should be all set if the webservice provides correctly encoded data. – jcaron Sep 06 '16 at 15:35
  • I am getting data as byte array after that ios/ native api will get the data and take it..but during display data gets corrupted after more then 3 char inserted in chat..Please let me know if you need more info..i will try tomorrow to copy paste sample code..please let me know if more info needed.. – anil kumar Sep 06 '16 at 18:04
  • Above problem is solved from java side by setting encoding as UTF in request\response layer + in DB tables and in hibernate layer with connection string included..Hibernate sample are .."?useUnicode=true&characterEncoding=UTF-8",utf8 utf8 true – anil kumar Sep 08 '16 at 12:15

0 Answers0