ios - Send a request with automatic encoding -
I am sending a request like this:
self.message = [self. Message Stringerling Occurrence Offstring: @ "& amp;" WithString: @ "§§§§"]; Self.message = [self. Message string barrier reeling ocronsoffstring: @ "'" with string: @ "- $ -"]; Self.message = [Self. Message string bearerening occurenceoffstring: @ "+" with string: @ "- & lt; # -"]; NSString * post = [NSString stringWithFormat: @ "id_user =% @ & amp; Message =% @ & amp; mode =% @ & amp; list_id =% @ and date_expired =% @ and Antrpraijh_ id =% @", id_user, self Messages, etc. ObjectForKey: @ "id_enterprise"]]; NSDTA * PostData = [Encoding to Use Data: NSUFF 8 string encoding permission; Lossy conversion: Yes]; NSString * postLength = [NSString stringWithFormat: @ "% lu", (unsigned long) [postdata length]]; NSMutableURLRequest * Request = [[NSMutableURLRequest alloc] init]; // etc So, why am I using stringburease? Because if '' '' or '& amp;' , Then it can cause some problems like ID_User = IZDs and TOI and message like URL. It seems that it will conflict with; for example.
So I wonder if there is a problem or this problem can be solved, anything other than that?
Use this method Pass your urlString with this method.
+ (NSString *) urlEncodeValue: (NSString *) str {if (str == null) {return @ ""; } NSString * result = (__Bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes (kCFAllocatorDefault, (__Briff CFStringRef) str, NULL, CFSTR ( "! * '\" () :: @ & Amp; = + $, /?% # []% " ), KCFStringEncodingUTF8); return result;}
Comments
Post a Comment