summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qchar.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:18:59 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:23:14 +1000
commit98dd1781d9256f68025d2a2db408f4f5947f3214 (patch)
treedbe1424abd90014edb5546c920ca585ed62b46e3 /src/corelib/tools/qchar.cpp
parent6c1bdc1854a7700c2b3a345b95f6a2fdca84037d (diff)
parentfa1b9070af66edb81b2a3735c1951f78b22bd666 (diff)
Merge master -> api_changes
Includes fixes for tst_qfiledialog2, tst_qtextedit autotests on mac. Change-Id: I49cac26894d31291a8339ccc1eb80b6a940f0827
Diffstat (limited to 'src/corelib/tools/qchar.cpp')
-rw-r--r--src/corelib/tools/qchar.cpp63
1 files changed, 16 insertions, 47 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index 01241dce6b..0261843a3a 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -413,33 +413,16 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn QChar::QChar(char ch)
+
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
*/
-QChar::QChar(char ch)
-{
-#ifndef QT_NO_CODEC_FOR_C_STRINGS
- if (QTextCodec::codecForCStrings())
- // #####
- ucs = QTextCodec::codecForCStrings()->toUnicode(&ch, 1).at(0).unicode();
- else
-#endif
- ucs = uchar(ch);
-}
/*!
+ \fn QChar::QChar(uchar ch)
+
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
*/
-QChar::QChar(uchar ch)
-{
-#ifndef QT_NO_CODEC_FOR_C_STRINGS
- if (QTextCodec::codecForCStrings()) {
- // #####
- char c = char(ch);
- ucs = QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode();
- } else
-#endif
- ucs = ch;
-}
/*!
\fn QChar::QChar(uchar cell, uchar row)
@@ -1256,49 +1239,35 @@ ushort QChar::toCaseFolded(ushort ucs2)
Returns the Latin-1 character equivalent to the QChar, or 0. This
is mainly useful for non-internationalized software.
- \sa toAscii(), unicode(), QTextCodec::codecForCStrings()
+ \sa toAscii(), unicode()
*/
/*!
- Returns the character value of the QChar obtained using the current
- codec used to read C strings, or 0 if the character is not representable
- using this codec. The default codec handles Latin-1 encoded text,
- but this can be changed to assist developers writing source code using
- other encodings.
+ \fn char QChar::toAscii() const
+
+ Returns the Latin-1 character value of the QChar, or 0 if the character is not
+ representable.
The main purpose of this function is to preserve ASCII characters used
in C strings. This is mainly useful for developers of non-internationalized
software.
- \sa toLatin1(), unicode(), QTextCodec::codecForCStrings()
+ \note It is not possible to distinguish a non-Latin 1 character from an ASCII 0
+ (NUL) character. Prefer to use unicode(), which does not have this ambiguity.
+
+ \sa toLatin1(), unicode()
*/
-char QChar::toAscii() const
-{
-#ifndef QT_NO_CODEC_FOR_C_STRINGS
- if (QTextCodec::codecForCStrings())
- // #####
- return QTextCodec::codecForCStrings()->fromUnicode(QString(*this)).at(0);
-#endif
- return ucs > 0xff ? 0 : char(ucs);
-}
/*!
+ \fn QChar QChar::fromAscii(char)
+
Converts the ASCII character \a c to it's equivalent QChar. This
is mainly useful for non-internationalized software.
An alternative is to use QLatin1Char.
- \sa fromLatin1(), unicode(), QTextCodec::codecForCStrings()
+ \sa fromLatin1(), unicode()
*/
-QChar QChar::fromAscii(char c)
-{
-#ifndef QT_NO_CODEC_FOR_C_STRINGS
- if (QTextCodec::codecForCStrings())
- // #####
- return QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode();
-#endif
- return QChar(ushort((uchar)c));
-}
#ifndef QT_NO_DATASTREAM
/*!