summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-02 10:16:50 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-02 10:16:50 (GMT)
commit037a3d01cbb0655a9d822a48f579bb346a0ef2c9 (patch)
tree8afd046bcf8d2e8281f3a0202cd0e366c273aa29 /src/corelib/tools/qstring.cpp
parent57d33781bd8e02904a85de7fc54f8f4e8bd299e6 (diff)
parent470b2de3e24b8eca056a31728a5e1039a9a25d79 (diff)
downloadQt-037a3d01cbb0655a9d822a48f579bb346a0ef2c9.zip
Qt-037a3d01cbb0655a9d822a48f579bb346a0ef2c9.tar.gz
Qt-037a3d01cbb0655a9d822a48f579bb346a0ef2c9.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1: qmake: subdirs template: make distclean target use QMAKE_DISTCLEAN qmake: fix warnings qmake: Remove macro and simplify string expression previously using it qmake: use isActiveConfig() instead of hand-crafting comparisons Fix missing namespace. Assistant: Fix spelling mistakes. Assistant: Use const references in foreach loops. optimization: get rid of QString::fromUtf16() usage document QString::fromUtf16() slowness remove duplicated calculation of length remove pointless conditionals micro-optimization optimize qhash() Designer/uic/related examples: Fix source code scanning issues II.
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index b9dd4d1..3388500 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -885,7 +885,7 @@ int QString::grow(int size)
QString QString::fromWCharArray(const wchar_t *string, int size)
{
if (sizeof(wchar_t) == sizeof(QChar)) {
- return fromUtf16((ushort *)string, size);
+ return QString((const QChar *)string, size);
} else {
return fromUcs4((uint *)string, size);
}
@@ -3857,6 +3857,12 @@ QString QString::fromUtf8(const char *str, int size)
If \a size is -1 (default), \a unicode must be terminated
with a 0.
+ This function checks for a Byte Order Mark (BOM). If it is missing,
+ host byte order is assumed.
+
+ This function is comparatively slow.
+ Use QString(const ushort *, int) if possible.
+
QString makes a deep copy of the Unicode data.
\sa utf16(), setUtf16()
@@ -3923,6 +3929,9 @@ QString& QString::setUnicode(const QChar *unicode, int size)
If \a unicode is 0, nothing is copied, but the string is still
resized to \a size.
+ Note that unlike fromUtf16(), this function does not consider BOMs and
+ possibly differing byte ordering.
+
\sa utf16(), setUnicode()
*/
@@ -4669,6 +4678,8 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
Returns the QString as a '\\0\'-terminated array of unsigned
shorts. The result remains valid until the string is modified.
+ The returned string is in host byte order.
+
\sa unicode()
*/
@@ -7740,7 +7751,7 @@ QString QStringRef::toString() const {
return QString();
if (m_size && m_position == 0 && m_size == m_string->size())
return *m_string;
- return QString::fromUtf16(reinterpret_cast<const ushort*>(m_string->unicode() + m_position), m_size);
+ return QString(m_string->unicode() + m_position, m_size);
}