source: trunk/doc/html/unicode.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 6.4 KB
RevLine 
[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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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
36computing platforms and with decent coverage over most of the world.
37It is also single-locale; it includes no code pages or other
38complexities that make software harder to write and test. There is no
39competing character set that's reasonably multiplatform. For these
40reasons, 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>
45has 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
58update</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
64strings 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
70support for migrating from C strings including fast (cached)
71translation to and from US-ASCII, and all the usual string
72operations.
73<li> Unicode-aware widgets where appropriate.
74<li> Unicode support detection on Windows, so that Qt provides Unicode
75even 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
78all 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
80widgets you write; it does not make much difference for slow typists
81in Western Europe or North America, but for fast typists or people
82using 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 &amp;</tt>s.
84<a href="qstring.html">QString</a> provides implicit casting from <tt>const char *</tt>
85so that things like
86<pre>
87 myLabel-&gt;setText( "Hello, Dolly!" );
88</pre>
89
90will work. There is also a function, <a href="qobject.html#tr">QObject::tr</a>(), that provides
91translation support, like this:
92<pre>
93 myLabel-&gt;setText( tr("Hello, Dolly!") );
94</pre>
95
96<p> tr() (simplifying somewhat) maps from <tt>const char *</tt> to a
97Unicode string, and uses installable <a href="qtranslator.html">QTranslator</a> objects to do the
98mapping.
99<p> Qt provides a number of built-in <a href="qtextcodec.html">QTextCodec</a> classes, that is,
100classes that know how to translate between Unicode and legacy
101encodings to support programs that must talk to other programs or
102read/write files in legacy file formats.
103<p> By default, conversion to/from <tt>const char *</tt> uses a
104locale-dependent codec. However, applications can easily find codecs
105for other locales, and set any open file or network connection to use
106a special codec. It is also possible to install new codecs, for
107encodings that the built-in ones do not support. (At the time of
108writing, Vietnamese/VISCII is one such example.)
109<p> Since US-ASCII and ISO-8859-1 are so common, there are also especially
110fast functions for mapping to and from them. For example, to open an
111application'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
117Unicode to whatever encoding the system and fonts provide.
118Depending on operating system, locale, font availability and Qt's
119support for the characters used, this conversion may be good or bad.
120We will extend this in upcoming versions, with emphasis on the most
121common 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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.