diff options
author | Florian Vichot <florian.vichot@gmail.com> | 2010-03-23 19:24:58 (GMT) |
---|---|---|
committer | Benjamin Poulain <benjamin.poulain@nokia.com> | 2010-03-23 19:24:58 (GMT) |
commit | 71832cfe6fa0005312f9a648f97d7ae9613a591f (patch) | |
tree | d460f2a441f1179fa605a418892f296ab11ba717 /src/corelib/tools/qstring.cpp | |
parent | 6da690f031420957dec795c2899f337c296eff0b (diff) | |
download | Qt-71832cfe6fa0005312f9a648f97d7ae9613a591f.zip Qt-71832cfe6fa0005312f9a648f97d7ae9613a591f.tar.gz Qt-71832cfe6fa0005312f9a648f97d7ae9613a591f.tar.bz2 |
Use the default codec with QString::vsprintf()
QString::vsprintf was not decoding the format string according to QTextCodec::codecForCString,
thus making qDebug("ééé") display improperly, even if using a utf8 terminal, utf8 source files
and a codec for cstrings configured as utf8. Added a unit test.
Merge-request: 530
Reviewed-by: Benjamin Poulain <benjamin.poulain@nokia.com>
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 464e77b..2f12b80 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -5104,8 +5104,19 @@ QString &QString::vsprintf(const char* cformat, va_list ap) const char *c = cformat; for (;;) { // Copy non-escape chars to result +#ifndef QT_NO_TEXTCODEC + int i = 0; + while (*(c + i) != '\0' && *(c + i) != '%') + ++i; + if (codecForCStrings) + result.append(codecForCStrings->toUnicode(c, i)); + else + result.append(fromLatin1(c, i)); + c += i; +#else while (*c != '\0' && *c != '%') result.append(QLatin1Char(*c++)); +#endif if (*c == '\0') break; |