Reputation: 359
I'm creating an app based on a API server. The server is currently in UTF-8 encoding.
Rather than write a line of code every time the API is accessed to re-encode text, I thought I may as well just set the server API to have the same text encoding as the app.
Only problem is I can't find out the default encoding!
Where would I find this information, and can I change the default encoding on the app?
Cheers!
Upvotes: 1
Views: 8265
Reputation: 34
NSString's static method will do the job
+ (NSStringEncoding)defaultCStringEncoding;
Upvotes: 0
Reputation: 24439
There is no default encoding. NSString
can have various encodings internally.
I know that on Mac OS X, ASCII, UTF-8 and UTF-16 w/ host byte order are always among possible internal representations, iOS shouldn't be different, though I'm not totally sure. I think it's safe to assume that stringWithUTF8String:
will not cause any extra re-encoding.
Upvotes: 3