0

目的の c でデコードする必要があるエンコードされた文字列がありますJavaScript escape()。解決策をあらゆる場所で検索しましたが、これがどのタイプのエンコードであるかさえわかりません。

サンプル文字列:

%3Cdiv%20id%3D%27wrapper%27%3E%3Cp%3EHello%20World%21%3C/p%3E%3C/div%3E
4

1 に答える 1

1

There is an NSString function you can use: stringByReplacingPercentEscapesUsingEncoding:

From the documentation:

Returns a new string made by replacing in the receiver all percent escapes with the matching characters as determined by a given encoding.

Typically you should be using NSUTF8StringEncoding for the encoding.

Example usage:

NSString *escaped = @"%3Cdiv%20id%3D%27wrapper%27%3E%3Cp%3EHello%20World%21%3C/p%3E%3C/div%3E";
NSString *unescaped = [escaped stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
于 2013-05-30T10:38:23.203 に答える