且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Objective-C中编码或解码URL

更新时间:2023-02-23 12:09:49

中文和日文字符与ASCII字符串编码不兼容是很自然的.如果您尝试通过Apple的方法对字符串进行转义(绝对应该避免代码重复),则将结果存储为Unicode字符串.使用以下编码之一:

It's natural that Chinese and Japanese characters don't work with ASCII string encoding. If you try to escape the string by Apple's methods, which you definitely should to avoid code duplication, store the result as a Unicode string. Use one of the following encodings:

NSUTF8StringEncoding
NSUTF16StringEncoding
NSShiftJISStringEncoding (not Unicode, Japanese-specific)