IOS URL Encode NSString, and the result is always (null)

when I use NSASCIIStringEncoding to encode some Chinese character for a GET request.

NSLog(@"%@",searchText); NSString *stringForSearch = [searchText stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; NSLog(@"%@",stringForSearch); 

2012-05-05 23: 51: 02.669 StarHopeFundingApprovalSystem [756: f803] δΈ­

2012-05-05 23: 51: 06.305 StarHopeFundingApprovalSystem [756: f803] (null)

And the first journal is a Chinese character, but the second journal is always (null). Help me with this, thanks in advance.

+4
source share
1 answer

Try using NSUTF8StringEncoding insted NSASCIIStringEncoding .

+7
source

Source: https://habr.com/ru/post/1410881/


All Articles