diff options
-rw-r--r-- | qmake/project.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/qmake/project.cpp b/qmake/project.cpp index 7351d1a..5f5745a 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -677,7 +677,23 @@ QMakeProject::reset() bool QMakeProject::parse(const QString &t, QMap<QString, QStringList> &place, int numLines) { - QString s = t.simplified(); + // To preserve the integrity of any UTF-8 characters in .pro file, temporarily replace the + // non-breaking space (0xA0) characters with another non-space character, so that + // QString::simplified() call will not replace it with space. + // Note: There won't be any two byte characters in .pro files, so 0x10A0 should be a safe + // replacement character. + static QChar nbsp(0xA0); + static QChar nbspFix(0x01A0); + QString s; + if (t.indexOf(nbsp) != -1) { + s = t; + s.replace(nbsp, nbspFix); + s = s.simplified(); + s.replace(nbspFix, nbsp); + } else { + s = t.simplified(); + } + int hash_mark = s.indexOf("#"); if(hash_mark != -1) //good bye comments s = s.left(hash_mark); |