On 26/12/12 17:02, Thiago Macieira wrote: > On quarta-feira, 26 de dezembro de 2012 16.42.44, Nikos Chantziaras wrote: >>> Why do you need the codec name anyway? >> >> So that I can tell another library what encoding to use for filenames >> when it wants to create files. > > Can't you tell it to use the default?
It doesn't know. At least not on Unix systems (on Windows, as you mention, UTF-16 is assumed and Windows API specific functions are used, since standard <stdio.h> routines aren't Unicode-aware there.) > By the way, on Windows you should always choose UTF-16, both on the Qt and the > 3rd-party library's side. The Windows "A" (ANSI) API as well as the POSIX- > style CRT API are unable to deal with all the possible file names that the > Windows "W" (Wide) API can deal with. > > QFile already uses the "W" API, so you don't have to do anything. > > But that means you must not use QFile::encodeName on Windows. Simply pass the > QString's original UTF-16 data and tell the other library to use the "W" API > too. > > Anything else, on Windows, is dead-on-arrival. Yep, thanks for the pointers. I assume that on POSIX this should cover pretty much everything: QTextCodec::codecForName(nl_langinfo(CODESET))->name() (Just in case nl_langinfo() doesn't return the preferred MIME name.) _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest