Wednesday, 15 June 2011

ios - NSString URL decode? -


I have tried many approaches, but this small string URL can not be decoded. NSString * was decoded; NSString * encoded = "field = id% 2CdeviceToken"; Decoded = (__breeze nssting *) CFURL creation stringbearingplanspercent scapeupping encoding (null, (CF stringerf) encoded, null, NSTF 8 string encoding); NSLog (@ "decoded string% @", decoded);

The same (!) Logs the string after saving percentage from the above code.

Is there a reliable solution? I think some types of RegEx solutions can work on the basis of some documents. instead of use CFSTR ("")

from:

characters touched escape

whose percentage escape sequence, such as% 20 for space characters, you want to leave intact Are there. To specify that no percentage of migrating is replaced by the zero pass, or the empty string (CFSTR ("")) to specify that all will be replaced.

  NSString * encoding = @ "fields = id% 2CdeviceToken"; NSString * decode = (__bridge_transfer NSString *) CFURLCreateStringByReplacingPercentEscapesUsingEncoding (zero, CFStringRef) encoding, CFSTR (""), kCFStringEncodingUTF8); NSLog (@ "decoded string% @", decoded);   

Prints:

2013-03-26 21: 48: 52.559 URLDecoding [28794: 303] decodedString areas = ida ??, a ?? ¬ Device Tokens

No comments:

Post a Comment