summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-09-30 09:52:51 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2014-11-05 10:46:01 +0100
commit54d4fb4f500dfb45d86b2046b90becd55783e48e (patch)
treeeb4fec7679e11485abab839d43a66e477fbfe282 /src/corelib/tools/qstring.cpp
parentb7d36614e9f00a3376dd19493eaf3ffc4ec431da (diff)
Fix QString::sprintf documentation
QString::sprintf does actually support all length modifiers, including %lld. The format string is also parsed as UTF-8. What's worthwile to mention, though, is that %lc and %ls is at odds with the standard, since wchar_t isn't necessarily 16 bits wide. Change-Id: I30cd22ec5b42035824dd98e3cdcc79d7adcc953a Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 3b18d31547..7d0607a2f7 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -5692,21 +5692,18 @@ QString QString::toUpper() const
Safely builds a formatted string from the format string \a cformat
and an arbitrary list of arguments.
- The %lc escape sequence expects a unicode character of type ushort
- (as returned by QChar::unicode()). The %ls escape sequence expects
- a pointer to a zero-terminated array of unicode characters of type
- ushort (as returned by QString::utf16()).
-
- \note This function expects a UTF-8 string for %s and Latin-1 for
- the format string.
-
- The format string supports most of the conversion specifiers
- provided by printf() in the standard C++ library. It doesn't
- honor the length modifiers (e.g. \c h for \c short, \c ll for
- \c{long long}). If you need those, use the standard snprintf()
- function instead:
-
- \snippet qstring/main.cpp 63
+ The format string supports the conversion specifiers, length modifiers,
+ and flags provided by printf() in the standard C++ library. The \a cformat
+ string and \c{%s} arguments must be UTF-8 encoded.
+
+ \note The \c{%lc} escape sequence expects a unicode character of type
+ \c char16_t, or \c ushort (as returned by QChar::unicode()).
+ The \c{%ls} escape sequence expects a pointer to a zero-terminated array
+ of unicode characters of type \c char16_t, or ushort (as returned by
+ QString::utf16()). This is at odds with the printf() in the standard C++
+ library, which defines \c {%lc} to print a wchar_t and \c{%ls} to print
+ a \c{wchar_t*}, and might also produce compiler warnings on platforms
+ where the size of \c {wchar_t} is not 16 bits.
\warning We do not recommend using QString::sprintf() in new Qt
code. Instead, consider using QTextStream or arg(), both of