[Qt-interest] Source files encoding

Marcelo Magno T. Sales mmtsales at gmail.com
Wed Oct 13 22:45:57 CEST 2010


Hello,

Editing/compiling a project in QT Creator 1.3.1 on Linux (Kubuntu 
10.04), all strings that contains accented characters are displayed 
wrong when the generated executable is run.
This can be solved by saving the source files as ISO8859-1 or by adding 
QString::fromUtf8() around the strings in the source. However, I'd 
rather use my system's default encoding (UTF-8) than saving every file 
as ISO8859-1 and having to select this encoding manually every time I 
open the file in QT Creator editor. Adding QString::fromUtf8() around 
every single string in the source code is not a very appealing solution 
either.
Although g++ documentation states it should default to utf-8 for its 
input files, I've tried to add:
QMAKE_CXXFLAGS += -finput-charset=utf-8
to the project file, but the problem persists.

Is there a way to compile from UTF-8 encoded sources in Linux and get 
the right strings displayed in the executable?

Thanks,

Marcelo



More information about the Qt-interest-old mailing list