Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 7761

qt4-doc-4.8.7-26.2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- unicode.qdoc -->
  <title>Qt 4.8: Unicode in Qt</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <div class="breadcrumb toolblock">
            <ul>
              <li class="first"><a href="index.html">Home</a></li>
              <!--  Breadcrumbs go here -->
<li>Unicode in Qt</li>
            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></li>
            </ul>
        </div>
        </div>
        <div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#qt-s-classes-for-working-with-strings">Qt's Classes for Working with Strings</a></li>
<li class="level1"><a href="#information-about-unicode-on-the-web">Information about Unicode on the Web</a></li>
<li class="level1"><a href="#the-standard">The Standard</a></li>
<li class="level1"><a href="#unicode-in-qt">Unicode in Qt</a></li>
</ul>
</div>
<h1 class="title">Unicode in Qt</h1>
<span class="subtitle"></span>
<!-- $$$unicode.html-description -->
<div class="descr"> <a name="details"></a>
<a name="unicode"></a><p>Unicode is a multi-byte character set, portable across all major computing platforms and with decent coverage over most of the world. It is also single-locale; it includes no code pages or other complexities that make software harder to write and test. There is no competing character set that's reasonably cross-platform. For these reasons, Unicode 4.0 is used as the native character set for Qt.</p>
<a name="qt-s-classes-for-working-with-strings"></a>
<h2>Qt's Classes for Working with Strings</h2>
<p>These classes are relevant when working with string data. For information about rendering text, see the <a href="richtext.html">Rich Text Processing</a> overview, and if your string data is in XML, see the <a href="xml-processing.html">XML Processing</a> overview.</p>
<table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qbytearray.html">QByteArray</a></p></td><td class="tblDescr"><p>Array of bytes</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qbytearraymatcher.html">QByteArrayMatcher</a></p></td><td class="tblDescr"><p>Holds a sequence of bytes that can be quickly matched in a byte array</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qchar.html">QChar</a></p></td><td class="tblDescr"><p>16-bit Unicode character</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qlatin1char.html">QLatin1Char</a></p></td><td class="tblDescr"><p>8-bit ASCII/Latin-1 character</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qlatin1string.html">QLatin1String</a></p></td><td class="tblDescr"><p>Thin wrapper around an US-ASCII/Latin-1 encoded string literal</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qlocale.html">QLocale</a></p></td><td class="tblDescr"><p>Converts between numbers and their string representations in various languages</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qstring.html">QString</a></p></td><td class="tblDescr"><p>Unicode character string</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qstringlist.html">QStringList</a></p></td><td class="tblDescr"><p>List of strings</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qstringmatcher.html">QStringMatcher</a></p></td><td class="tblDescr"><p>Holds a sequence of characters that can be quickly matched in a Unicode string</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qstringref.html">QStringRef</a></p></td><td class="tblDescr"><p>Thin wrapper around QString substrings</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtextboundaryfinder.html">QTextBoundaryFinder</a></p></td><td class="tblDescr"><p>Way of finding Unicode text boundaries in a string</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtextstream.html">QTextStream</a></p></td><td class="tblDescr"><p>Convenient interface for reading and writing text</p></td></tr>
</table>
<a name="information-about-unicode-on-the-web"></a>
<h2>Information about Unicode on the Web</h2>
<p>The <a href="http://www.unicode.org/">Unicode Consortium</a> has a number of documents available, including</p>
<ul>
<li><a href="http://www.unicode.org/unicode/standard/principles.html">A technical introduction to Unicode</a></li>
<li><a href="http://www.unicode.org/unicode/standard/standard.html">The home page for the standard</a></li>
</ul>
<a name="the-standard"></a>
<h2>The Standard</h2>
<p>The current version of the standard is <a href="http://www.unicode.org/versions/Unicode5.1.0/">Unicode 5.1&#x2e;0</a>.</p>
<p>Previous printed versions of the specification:</p>
<ul>
<li><a href="http://www.amazon.com/Unicode-Standard-Version-5-0-5th/dp/0321480910/trolltech/t">The Unicode Standard, Version 5.0</a></li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0321185781/trolltech/t">The Unicode Standard, version 4.0</a></li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0201616335/trolltech/t">The Unicode Standard, version 3.2</a></li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0201473459/trolltech/t">The Unicode Standard, version 2.0</a> &mdash; 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&#x2e;9 data files</a> at <a href="http://www.unicode.org">http://www.unicode.org</a>.</li>
</ul>
<a name="unicode-in-qt"></a>
<h2>Unicode in Qt</h2>
<p>In Qt, and in most applications that use Qt, most or all user-visible strings are stored using Unicode. Qt provides:</p>
<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>
<li>Translation from Input Methods and 8-bit keyboard input.</li>
<li>Translation to legacy character sets for on-screen display.</li>
<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 US-ASCII, and all the usual string operations.</li>
<li>Unicode-aware widgets where appropriate.</li>
<li>Unicode support detection on Windows, so that Qt provides Unicode even on Windows platforms that do not support it natively.</li>
</ul>
<p>To fully benefit from Unicode, we recommend using <a href="qstring.html">QString</a> for storing all user-visible strings, and performing all text file I/O using <a href="qtextstream.html">QTextStream</a>. Use <a href="qkeyevent.html#text">QKeyEvent::text</a>() for keyboard input in any custom widgets you write; it does not make much difference for slow typists in Western Europe or North America, but for fast typists or people using special input methods using text() is beneficial.</p>
<p>All the function arguments in Qt that may be user-visible strings, <a href="qlabel.html#text-prop">QLabel::setText</a>() and a many others, take <tt>const QString &amp;</tt>s. <a href="qstring.html">QString</a> provides implicit casting from <tt>const char *</tt> so that things like</p>
<pre class="cpp"> label<span class="operator">-</span><span class="operator">&gt;</span>setText(<span class="string">&quot;Password:&quot;</span>);</pre>
<p>will work. There is also a function, <a href="qobject.html#tr">QObject::tr</a>(), that provides translation support, like this:</p>
<pre class="cpp"> label<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Password:&quot;</span>));</pre>
<p><a href="qobject.html#tr">QObject::tr</a>() maps from <tt>const char *</tt> to a Unicode string, and uses installable <a href="qtranslator.html">QTranslator</a> objects to do the mapping.</p>
<p>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 legacy encodings to support programs that must talk to other programs or read/write files in legacy file formats.</p>
<p>By default, conversion to/from <tt>const char *</tt> uses a locale-dependent codec. However, applications 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 such example.)</p>
<p>Since US-ASCII and ISO-8859-1 are so common, there are also especially fast functions for mapping to and from them. For example, to open an application's icon one might do this:</p>
<pre class="cpp"> <span class="type"><a href="qfile.html">QFile</a></span> file(<span class="type"><a href="qstring.html">QString</a></span><span class="operator">::</span>fromLatin1(<span class="string">&quot;appicon.png&quot;</span>));</pre>
<p>or</p>
<pre class="cpp"> <span class="type"><a href="qfile.html">QFile</a></span> file(QLatin1String(<span class="string">&quot;appicon.png&quot;</span>));</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 will extend this in upcoming versions, with emphasis on the most common locales first.</p>
</div>
<p><b>See also </b><a href="internationalization.html">Internationalization with Qt</a>.</p>
<!-- @@@unicode.html -->
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
      Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Qt and respective logos are trademarks of The Qt Company Ltd 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
  </div>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>