NSUTF8StringEncoding Target

NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error]; NSString *data = [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding]; 

Could you explain the purpose of NSUTF8StringEncoding to me, does it encode all the data? Can you give an example of NSUTF8StringEncoding with input and output?

+4
source share
1 answer

You must specify NSString using an encoding that NSData bytes can be interpreted as a valid string. However, it will not change / convert your string between encodings. If the NSData object contains a sequence of bytes that is not valid in UTF-8, it will simply return zero.

+7
source

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


All Articles