Reputation: 12444
Currently I am download data from a server and I have this line to get that NSData into a NSString.
NSString *txt = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
How would I go from here to convert that NSString into a UTF8 string?
Thanks!
Upvotes: 3
Views: 11396
Reputation: 846
Change NSASCIIStringEncoding
to NSUTF8StringEncoding
.
I ran a quick test now with some dummy data and seemed to work fine with just that one line.
Upvotes: 1
Reputation: 6139
NSData *utf8Data = [txt dataUsingEncoding:NSUTF8StringEncoding];
Upvotes: 5