?? qchar.cpp
字號(hào):
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the QtCore module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file. Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/// Don't define it while compiling this module, or USERS of Qt will// not be able to link.#ifdef QT_NO_CAST_FROM_ASCII#undef QT_NO_CAST_FROM_ASCII#endif#ifdef QT_NO_CAST_TO_ASCII#undef QT_NO_CAST_TO_ASCII#endif#include "qchar.h"#include "qdatastream.h"#include "qunicodetables_p.h"#include "qtextcodec.h"#ifndef QT_NO_CODEC_FOR_C_STRINGS#ifdef QT_NO_TEXTCODEC#define QT_NO_CODEC_FOR_C_STRINGS#endif#endif/*! \class QLatin1Char \brief The QLatin1Char class provides an 8-bit ASCII/Latin-1 character. \ingroup text This class is only useful to avoid the codec for C strings business in the QChar(ch) constructor. You can avoid it by writing QChar(ch, 0). \sa QChar, QLatin1String, QString*//*! \fn const char QLatin1Char::toLatin1() const Converts a Latin-1 character to an 8-bit ASCII representation of the character.*//*! \fn const ushort QLatin1Char::unicode() const Converts a Latin-1 character to an 16-bit-encoded Unicode representation of the character.*//*! \fn QLatin1Char::QLatin1Char(char c) Constructs a Latin-1 character for \a c. This constructor should be used when the encoding of the input character is known to be Latin-1.*//*! \class QChar \brief The QChar class provides a 16-bit Unicode character. \ingroup text \reentrant In Qt, Unicode characters are 16-bit entities without any markup or structure. This class represents such an entity. It is lightweight, so it can be used everywhere. Most compilers treat it like a \c{unsigned short}. QChar provides a full complement of testing/classification functions, converting to and from other formats, converting from composed to decomposed Unicode, and trying to compare and case-convert if you ask it to. The classification functions include functions like those in the standard C++ header \<cctype\> (formerly \<ctype.h\>), but operating on the full range of Unicode characters. They all return true if the character is a certain type of character; otherwise they return false. These classification functions are isNull() (returns true if the character is '\\0'), isPrint() (true if the character is any sort of printable character, including whitespace), isPunct() (any sort of punctation), isMark() (Unicode Mark), isLetter() (a letter), isNumber() (any sort of numeric character, not just 0-9), isLetterOrNumber(), and isDigit() (decimal digits). All of these are wrappers around category() which return the Unicode-defined category of each character. QChar also provides direction(), which indicates the "natural" writing direction of this character. The joining() function indicates how the character joins with its neighbors (needed mostly for Arabic) and finally hasMirrored(), which indicates whether the character needs to be mirrored when it is printed in its "unnatural" writing direction. Composed Unicode characters (like \aring) can be converted to decomposed Unicode ("a" followed by "ring above") by using decomposition(). In Unicode, comparison is not necessarily possible and case conversion is very difficult at best. Unicode, covering the "entire" world, also includes most of the world's case and sorting problems. operator==() and friends will do comparison based purely on the numeric Unicode value (code point) of the characters, and toUpper() and toLower() will do case changes when the character has a well-defined uppercase/lowercase equivalent. For locale-dependent comparisons, use QString::localeAwareCompare(). The conversion functions include unicode() (to a scalar), toLatin1() (to scalar, but converts all non-Latin-1 characters to 0), row() (gives the Unicode row), cell() (gives the Unicode cell), digitValue() (gives the integer value of any of the numerous digit characters), and a host of constructors. QChar provides constructors and cast operators that make it easy to convert to and from traditional 8-bit \c{char}s. If you defined \c QT_NO_CAST_FROM_ASCII and \c QT_NO_CAST_TO_ASCII, as explained in the QString documentation, you will need to explicitly call fromAscii() or fromLatin1(), or use QLatin1Char, to construct a QChar from an 8-bit \c char, and you will need to call toAscii() or toLatin1() to get the 8-bit value back. \sa QString, Unicode, QLatin1Char*//*! \enum QChar::UnicodeVersion Specifies which version of the \l{http://www.unicode.org/}{Unicode standard} introduced a certain character. \value Unicode_1_1 Version 1.1. \value Unicode_2_0 Version 2.0. \value Unicode_2_1_2 Version 2.1.2. \value Unicode_3_0 Version 3.0. \value Unicode_3_1 Version 3.1. \value Unicode_3_2 Version 3.2. \value Unicode_4_0 Version 4.0. \value Unicode_Unassigned The value is not assigned to any character in version 4.0 of Unicode. \sa unicodeVersion()*//*! \enum QChar::Category This enum maps the Unicode character categories. The following characters are normative in Unicode: \value Mark_NonSpacing Unicode class name Mn \value Mark_SpacingCombining Unicode class name Mc \value Mark_Enclosing Unicode class name Me \value Number_DecimalDigit Unicode class name Nd \value Number_Letter Unicode class name Nl \value Number_Other Unicode class name No \value Separator_Space Unicode class name Zs \value Separator_Line Unicode class name Zl \value Separator_Paragraph Unicode class name Zp \value Other_Control Unicode class name Cc \value Other_Format Unicode class name Cf \value Other_Surrogate Unicode class name Cs \value Other_PrivateUse Unicode class name Co \value Other_NotAssigned Unicode class name Cn The following categories are informative in Unicode: \value Letter_Uppercase Unicode class name Lu \value Letter_Lowercase Unicode class name Ll \value Letter_Titlecase Unicode class name Lt \value Letter_Modifier Unicode class name Lm \value Letter_Other Unicode class name Lo \value Punctuation_Connector Unicode class name Pc \value Punctuation_Dash Unicode class name Pd \value Punctuation_Open Unicode class name Ps \value Punctuation_Close Unicode class name Pe \value Punctuation_InitialQuote Unicode class name Pi \value Punctuation_FinalQuote Unicode class name Pf \value Punctuation_Other Unicode class name Po \value Symbol_Math Unicode class name Sm \value Symbol_Currency Unicode class name Sc \value Symbol_Modifier Unicode class name Sk \value Symbol_Other Unicode class name So \value NoCategory Qt cannot find an appropriate category for the character. \omitvalue Punctuation_Dask \sa category()*//*! \enum QChar::Direction This enum type defines the Unicode direction attributes. See the \l{http://www.unicode.org/}{Unicode Standard} for a description of the values. In order to conform to C/C++ naming conventions "Dir" is prepended to the codes used in the Unicode Standard. \value DirAL \value DirAN \value DirB \value DirBN \value DirCS \value DirEN \value DirES \value DirET \value DirL \value DirLRE \value DirLRO \value DirNSM \value DirON \value DirPDF \value DirR \value DirRLE \value DirRLO \value DirS \value DirWS \sa direction()*//*! \enum QChar::Decomposition This enum type defines the Unicode decomposition attributes. See the \l{http://www.unicode.org/}{Unicode Standard} for a description of the values. \value NoDecomposition \value Canonical \value Circle \value Compat \value Final \value Font \value Fraction \value Initial \value Isolated \value Medial \value Narrow \value NoBreak \value Small \value Square \value Sub \value Super \value Vertical \value Wide \omitvalue Single \sa decomposition()*//*! \enum QChar::Joining This enum type defines the Unicode joining attributes. See the \l{http://www.unicode.org/}{Unicode Standard} for a description of the values. \value Center \value Dual \value OtherJoining \value Right \sa joining()*//*! \enum QChar::CombiningClass \internal This enum type defines names for some of the Unicode combining classes. See the \l{http://www.unicode.org/}{Unicode Standard} for a description of the values. \value Combining_Above \value Combining_AboveAttached \value Combining_AboveLeft \value Combining_AboveLeftAttached \value Combining_AboveRight \value Combining_AboveRightAttached \value Combining_Below \value Combining_BelowAttached \value Combining_BelowLeft \value Combining_BelowLeftAttached \value Combining_BelowRight \value Combining_BelowRightAttached \value Combining_DoubleAbove \value Combining_DoubleBelow \value Combining_IotaSubscript \value Combining_Left \value Combining_LeftAttached \value Combining_Right \value Combining_RightAttached*//*! \enum QChar::SpecialCharacter \value Null A QChar with this value isNull(). \value Nbsp Non-breaking space. \value ReplacementCharacter \value ObjectReplacementCharacter \value ByteOrderMark \value ByteOrderSwapped \value ParagraphSeparator \value LineSeparator \omitvalue null \omitvalue replacement \omitvalue byteOrderMark \omitvalue byteOrderSwapped \omitvalue nbsp*//*! \fn void QChar::setCell(uchar cell) \internal*//*! \fn void QChar::setRow(uchar row) \internal*//*! \fn QChar::QChar() Constructs a null QChar ('\\0'). \sa isNull()*//*! \fn QChar::QChar(QLatin1Char ch) Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.*//*! \fn QChar::QChar(SpecialCharacter ch) Constructs a QChar for the predefined character value \a 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);}/*! 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) Constructs a QChar for Unicode cell \a cell in row \a row. \sa cell(), row()*//*! \fn QChar::QChar(ushort code) Constructs a QChar for the character with Unicode code point \a code.*//*! \fn QChar::QChar(short code) Constructs a QChar for the character with Unicode code point \a code.*//*! \fn QChar::QChar(uint code) Constructs a QChar for the character with Unicode code point \a code.*//*!
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -