Re: warning about %s in format string
Because NSString doesn’t know what text encoding the C string uses, so it just uses the process’s default encoding. This default encoding varies according to the user's locale, and also (last I checked) even if that locale is English (or most European languages) the encoding is not something useful like UTF-8 but rather the incredibly obsolete MacRoman. The tl;dr is that if you format a non-ASCII C string with “%s” it's probably going to get mangled. In your example above, this would occur if the source file or any parent directory had a non-ASCII name. (This is the same reason why -[NSString initWithCString:] is deprecated.) —Jens |
|