[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/unicode.doc:36 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>About Unicode</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>About Unicode</h1>
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | <p> Unicode is a multi-byte character set, portable across all major
|
---|
| 36 | computing platforms and with decent coverage over most of the world.
|
---|
| 37 | It is also single-locale; it includes no code pages or other
|
---|
| 38 | complexities that make software harder to write and test. There is no
|
---|
| 39 | competing character set that's reasonably multiplatform. For these
|
---|
| 40 | reasons, Trolltech uses Unicode as the native character set for Qt
|
---|
| 41 | (since version 2.0).
|
---|
| 42 | <p> <h2> Information about Unicode on the web.
|
---|
| 43 | </h2>
|
---|
| 44 | <a name="1"></a><p> The <a href="http://www.unicode.org">Unicode Consortium</a>
|
---|
| 45 | has a number of documents available, including
|
---|
| 46 | <p> <ul>
|
---|
| 47 | <p> <li> <a href="http://www.unicode.org/unicode/standard/principles.html">A technical introduction to Unicode</a>
|
---|
| 48 | <li> <a href="http://www.unicode.org/unicode/standard/standard.html">The home page for the standard</a>
|
---|
| 49 | <p> </ul>
|
---|
| 50 | <p> <h2> The Standard
|
---|
| 51 | </h2>
|
---|
| 52 | <a name="2"></a><p> The current version of the standard is 3.2
|
---|
| 53 | <p> <ul>
|
---|
| 54 | <p> <li> <a href="http://www.amazon.com/exec/obidos/ASIN/0201616335/trolltech/t">The Unicode Standard, version 3.2.</a> See also
|
---|
| 55 | <a href="http://www.unicode.org/unicode/standard/versions/">its home page.</a>
|
---|
| 56 | <li> <a href="http://www.amazon.com/exec/obidos/ASIN/0201473459/trolltech/t">The Unicode Standard, version 2.0.</a> See also the
|
---|
| 57 | <a href="http://www.unicode.org/unicode/reports/tr8.html">2.1
|
---|
| 58 | update</a> and
|
---|
| 59 | <a href="http://www.unicode.org/unicode/standard/versions/enumeratedversions.html#Unicode">2.1.9 the 2.1.9 data files</a> at www.unicode.org.
|
---|
| 60 | <p> </ul>
|
---|
| 61 | <p> <h2> Unicode in Qt
|
---|
| 62 | </h2>
|
---|
| 63 | <a name="3"></a><p> In Qt, and in most applications that use Qt, most or all user-visible
|
---|
| 64 | strings are stored using Unicode. Qt provides:
|
---|
| 65 | <p> <ul>
|
---|
| 66 | <p> <li> Translation to/from legacy encodings for file I/O: see <a href="qtextcodec.html">QTextCodec</a> and <a href="qtextstream.html">QTextStream</a>.
|
---|
| 67 | <li> Translation from Input Methods and 8-bit keyboard input.
|
---|
| 68 | <li> Translation to legacy character sets for on-screen display.
|
---|
| 69 | <li> A string class, <a href="qstring.html">QString</a>, that stores Unicode characters, with
|
---|
| 70 | support for migrating from C strings including fast (cached)
|
---|
| 71 | translation to and from US-ASCII, and all the usual string
|
---|
| 72 | operations.
|
---|
| 73 | <li> Unicode-aware widgets where appropriate.
|
---|
| 74 | <li> Unicode support detection on Windows, so that Qt provides Unicode
|
---|
| 75 | even on Windows platforms that do not support it natively.
|
---|
| 76 | <p> </ul>
|
---|
| 77 | <p> To fully benefit from Unicode, we recommend using <a href="qstring.html">QString</a> for storing
|
---|
| 78 | all user-visible strings, and performing all text file I/O using
|
---|
| 79 | <a href="qtextstream.html">QTextStream</a>. Use <a href="qkeyevent.html#text">QKeyEvent::text</a>() for keyboard input in any custom
|
---|
| 80 | widgets you write; it does not make much difference for slow typists
|
---|
| 81 | in Western Europe or North America, but for fast typists or people
|
---|
| 82 | using special input methods using text() is beneficial.
|
---|
| 83 | <p> All the function arguments in Qt that may be user-visible strings, <a href="qlabel.html#setText">QLabel::setText</a>() and a many others, take <tt>const QString &</tt>s.
|
---|
| 84 | <a href="qstring.html">QString</a> provides implicit casting from <tt>const char *</tt>
|
---|
| 85 | so that things like
|
---|
| 86 | <pre>
|
---|
| 87 | myLabel->setText( "Hello, Dolly!" );
|
---|
| 88 | </pre>
|
---|
| 89 |
|
---|
| 90 | will work. There is also a function, <a href="qobject.html#tr">QObject::tr</a>(), that provides
|
---|
| 91 | translation support, like this:
|
---|
| 92 | <pre>
|
---|
| 93 | myLabel->setText( tr("Hello, Dolly!") );
|
---|
| 94 | </pre>
|
---|
| 95 |
|
---|
| 96 | <p> tr() (simplifying somewhat) maps from <tt>const char *</tt> to a
|
---|
| 97 | Unicode string, and uses installable <a href="qtranslator.html">QTranslator</a> objects to do the
|
---|
| 98 | mapping.
|
---|
| 99 | <p> Qt provides a number of built-in <a href="qtextcodec.html">QTextCodec</a> classes, that is,
|
---|
| 100 | classes that know how to translate between Unicode and legacy
|
---|
| 101 | encodings to support programs that must talk to other programs or
|
---|
| 102 | read/write files in legacy file formats.
|
---|
| 103 | <p> By default, conversion to/from <tt>const char *</tt> uses a
|
---|
| 104 | locale-dependent codec. However, applications can easily find codecs
|
---|
| 105 | for other locales, and set any open file or network connection to use
|
---|
| 106 | a special codec. It is also possible to install new codecs, for
|
---|
| 107 | encodings that the built-in ones do not support. (At the time of
|
---|
| 108 | writing, Vietnamese/VISCII is one such example.)
|
---|
| 109 | <p> Since US-ASCII and ISO-8859-1 are so common, there are also especially
|
---|
| 110 | fast functions for mapping to and from them. For example, to open an
|
---|
| 111 | application's icon one might do this:
|
---|
| 112 | <pre>
|
---|
| 113 | <a href="qfile.html">QFile</a> f( QString::<a href="qstring.html#fromLatin1">fromLatin1</a>("appicon.png") );
|
---|
| 114 | </pre>
|
---|
| 115 |
|
---|
| 116 | <p> Regarding output, Qt will do a best-effort conversion from
|
---|
| 117 | Unicode to whatever encoding the system and fonts provide.
|
---|
| 118 | Depending on operating system, locale, font availability and Qt's
|
---|
| 119 | support for the characters used, this conversion may be good or bad.
|
---|
| 120 | We will extend this in upcoming versions, with emphasis on the most
|
---|
| 121 | common locales first.
|
---|
| 122 | <p>
|
---|
| 123 | <!-- eof -->
|
---|
| 124 | <p><address><hr><div align=center>
|
---|
| 125 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 126 | <td>Copyright © 2007
|
---|
| 127 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 128 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 129 | </table></div></address></body>
|
---|
| 130 | </html>
|
---|