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