I'm dealing with an urlencoded string in objective-c. Is there a foundation function that actually reverse the urlENCODING?
The string received is like: K%FChlschrank but should be after decoding Kühlschrank
See Question&Answers more detail:osI'm dealing with an urlencoded string in objective-c. Is there a foundation function that actually reverse the urlENCODING?
The string received is like: K%FChlschrank but should be after decoding Kühlschrank
See Question&Answers more detail:osI made a quick category to help resolve this :)
@interface NSString (stringByDecodingURLFormat)
- (NSString *)stringByDecodingURLFormat;
@end
@implementation NSString
- (NSString *)stringByDecodingURLFormat
{
NSString *result = [(NSString *)self stringByReplacingOccurrencesOfString:@"+" withString:@" "];
result = [result stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
return result;
}
@end
Once defined, this quickly can handle an encoded string:
NSString *decodedString = [myString stringByDecodingURLFormat];
Plenty of other ways to implement.