Replace tab in NSString with \t

北战南征 提交于 2019-12-31 03:03:13

问题


I'm parsing json with SBJson.
I receive an error "-JSONValue failed. Error is: Unescaped control character [0x09]" when parsing my json string, it has unencoded tab. How to replace this tab in my json string to \t? If i remove tab manualy, everything is good. Or how to encode this tab properly?


回答1:


You can use stringByReplacingOccurrencesOfString:withString::

NSString * newJsonString = [oldJsonString stringByReplacingOccurrencesOfString:@"\t" withString:@"\\t"];


来源:https://stackoverflow.com/questions/7400514/replace-tab-in-nsstring-with-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!