Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QApplication in unicode

Tags:

c++

unicode

qt

QApplication's constructor takes an (int argc, char**argv) to handle any Qt specific commandline arguments.

What if my app is in unicode? And I have a wchar_t** argv?

It seems a bit silly to create a char* copy of all the commandline args to pass to a library that is itself unicode.

like image 666
Martin Beckett Avatar asked Nov 01 '10 18:11

Martin Beckett


1 Answers

Yes, it would be. If it wasn't for this note:

Warning: On Unix, this list is built from the argc and argv parameters passed to the constructor in the main() function. The string-data in argv is interpreted using QString::fromLocal8Bit(); hence it is not possible to pass, for example, Japanese command line arguments on a system that runs in a Latin1 locale. Most modern Unix systems do not have this limitation, as they are Unicode-based.

On NT-based Windows, this limitation does not apply either. On Windows, the arguments() are not built from the contents of argv/argc, as the content does not support Unicode. Instead, the arguments() are constructed from the return value of GetCommandLine(). As a result of this, the string given by arguments().at(0) might not be the program name on Windows, depending on how the application was started.

Admittedly, I don't get the word either.

like image 62
Hans Passant Avatar answered Nov 19 '22 08:11

Hans Passant