Resolve URL Chinese problem encoding
-(NSString *) encodeurlwithstring: (NSString *) unescapedstring{
NSString *outputstr = (NSString *) cfurlcreatestringbyaddingpercentescapes (Kcfallocatordefault, CFStringRef) Unescapedstring,null, (Cfstringref) @ "!* ' ();: @&=+$,/?%#[]", kCFStringEncodingUTF8);
return outputstr;
}
Decoding
-(NSString *) decodeurlwithstring: (NSString *) str{
NSString *string3 = [str stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding];
return string3;
}
Remove the spaces at both ends of the input box
-(NSString *) Deletewhitespacewithstr: (NSString *) str{
return [str stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]];
}
Remove the middle space in the input box
-(NSString *) Removespace: (NSString *) str{
return [str stringbyreplacingoccurrencesofstring:@ "" withstring:@ "];
}
A more practical method