开发者

Non english character in NSString

开发者 https://www.devze.com 2023-02-13 02:45 出处:网络
In my application server give response text in non English characters. I parse this data and store this in string.

In my application server give response text in non English characters. I parse this data and store this in string.

I want string operation on this string but due to non English characters, I got error and crash.

Specially this happen when hindi characters available in response.

Please help me.

开发者_C百科

Thanks in advance.


The problem could be with the way your are getting the data from the server and storing it in the NSString. You might be decoding your data with ASCII characterset.

Try with this NSUTF8StringEncoding. This could solve your problem:

NSString *string =  [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
0

精彩评论

暂无评论...
验证码 换一张
取 消