If you blog it they will come?

Monday, November 21, 2011

Don't use defaultCStringEncoding

It isn't exactly news that this innocuous-sounding parameter is "considered harmful."
But this fact needs a bit more SEO-juice, so here's another voice speaking out against defaultCStringEncoding:

(from NSString.h):

/* User-dependent encoding who value is derived from user's default language
and potentially other factors. The use of this encoding might sometimes be needed
when interpreting user documents with unknown encodings, in the absence of other hints.
This encoding should be used rarely, if at all. Note that some potential values
here might result in unexpected encoding conversions of even fairly straightforward
NSString content
--- for instance, punctuation characters with a bidirectional encoding.
+ (NSStringEncoding)defaultCStringEncoding; //Should be rarely used