diff options
author | Robin Burchell <robin+qt@viroteck.net> | 2012-01-30 14:23:22 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-22 14:00:32 +0100 |
commit | 186692f81f2612c3cf3a4090cbf949f2fb1558f8 (patch) | |
tree | e4506e520a88a1c75086516a1edeb1ab2fb4d057 /src/corelib/tools/qchar.h | |
parent | 9d173c92183c30144e8bd4f115b2cd93c3da0d40 (diff) |
Remove custom text codec for C strings.
This setting is extremely harmful, as code cannot know whether or not to expect
it. It also made the behaviour of QString::fromAscii and ::toAscii unintuitive,
and caused a lot of people to make mistakes with it.
Change-Id: I2f429fa7ef93bd75bb93a7f64c56db15b7283388
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qchar.h')
-rw-r--r-- | src/corelib/tools/qchar.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index df3d7eac33..d55fcdba89 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -86,9 +86,8 @@ public: Q_DECL_CONSTEXPR QChar(QLatin1Char ch) : ucs(ch.unicode()) {} // implicit #ifndef QT_NO_CAST_FROM_ASCII - // these two constructors are NOT inline const_expr! - QT_ASCII_CAST_WARN_CONSTRUCTOR explicit QChar(char c); - QT_ASCII_CAST_WARN_CONSTRUCTOR explicit QChar(uchar c); + QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTEXPR explicit QChar(char c) : ucs(uchar(c)) { } + QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTEXPR explicit QChar(uchar c) : ucs(c) { } #endif // Unicode information @@ -222,13 +221,13 @@ public: UnicodeVersion unicodeVersion() const; - char toAscii() const; + inline char toAscii() const; inline char toLatin1() const; inline ushort unicode() const { return ucs; } inline ushort &unicode() { return ucs; } - static QChar fromAscii(char c); - static QChar fromLatin1(char c); + static inline QChar fromAscii(char c); + static inline QChar fromLatin1(char c); inline bool isNull() const { return ucs == 0; } bool isPrint() const; @@ -344,8 +343,10 @@ private: Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE); +inline char QChar::toAscii() const { return ucs > 0xff ? 0 : char(ucs); } inline char QChar::toLatin1() const { return ucs > 0xff ? '\0' : char(ucs); } inline QChar QChar::fromLatin1(char c) { return QChar(ushort(uchar(c))); } +inline QChar QChar::fromAscii(char c) { return QChar(ushort(uchar(c))); } inline void QChar::setCell(uchar acell) { ucs = ushort((ucs & 0xff00) + acell); } |