[SDL] Unicode filenames
Ryan C. Gordon
icculus at icculus.org
Mon Mar 1 09:17:00 PST 2010
> I think modern Unix-like systems consider 8-bit character strings to be
> UTF-8 strings already. So just use fopen?
That's the convention, but it's not enforced, I think. A Linux
filesystem can have any byte in the filename except null characters and
'/' ... if you give it data that's not valid UTF-8, it'll still work.
...it'll probably confuse all sorts of software, but it'll "work".
I think Mac OS X explicitly says it wants UTF-8 when using the POSIX
APIs (they are not stored in UTF-8 in the filesystem, it just converts
for you). Non-POSIX APIs on the Mac want CFStrings or NSStrings or what
not, which handle unicode details behind the scenes (you can create
CFStrings from UTF-8 data).
Windows _never_ wants UTF-8. Since Windows 98, they've provided an API
to convert to/from UTF-8 (and full Unicode support in all NT-based
OSes), but they want UTF-16. If you try to pass UTF-8 bytes to the APIs
that take a char * instead of a WCHAR *, it thinks you're using the
current "codepage" and it will not work, ever. These have to be manually
converted (SDL does this internally for you).
SDL wants UTF-8 whenever it asks for filenames, and converts as
appropriate for the system.
--ryan.
More information about the SDL
mailing list