English 中文(简体)
URL 扼杀客观代表的越狱? (“最佳编码”)
原标题:URL string escape representation in objective-c? ("percent encoding")

IOS5下,我想在客观的c下完成一项非常简单的任务:将URL string改为其逃脱的代表。

我尝试了许多办法,但似乎都没有工作。

我不能说话。 通过补充PercentE病因:NSASCII编码编码工作。 它改写了诸如Paíűőüöúóé之类的信件,但并不将他人改成像 = 。

我也希望有一个职能,如Uri.E/2008/6DataString()。

感谢!

最佳回答

您可在<代码>NSString上添加一类内容,如:

- (NSString *)ps_stringByAddingPercentEscapes;
{
    return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, 
                                                               (CFStringRef)self, 
                                                               NULL, 
                                                               (CFStringRef)@":/?#[]@!$&’()*+,;=", 
                                                               kCFStringEncodingUTF8) autorelease];
}

Replace @":/?#[]@!$&’()*+,;=" for the chars that you care about.

问题回答

暂无回答




相关问题
How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...

Do I need to escape this?

It might be a bit unusual, but I need to echo <?php. However, I think that PHP treats it as an actual <?php and starts executing code instead of treating it as a string. How can I escape <?...

热门标签