summaryrefslogtreecommitdiff
path: root/doc/src/frameworks-technologies/unicode.qdoc
blob: a5ffd836a7e296dd2a731ee9d3a0884fbd5cffbf (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \group string-processing
    \title Classes for String Data

    \brief Classes for working with string data.

    These classes are relevant when working with string data. See the
    \l{Unicode in Qt}{information about support for Unicode in Qt} for
    more information.
*/


/*!
    \page unicode.html
    \title Unicode in Qt
    \brief Information about support for Unicode in Qt.

    \keyword Unicode


    \l{http://www.unicode.org/}{Unicode}
    is the standard for encoding text in almost all languages
    spoken in the world. It is nowadays used as the native encoding
    for text on most modern operating systems. The major exception is
    Microsoft Windows that still has a dual system supporting code pages
    and Unicode for applications.

    Qt 5.0 uses and fully supports version 6.2 of the Unicode standard.

    \section1 Qt's Classes for Working with Strings

    These classes are relevant when working with string data. For information
    about rendering text, see the \l{Rich Text Processing} overview, and if
    your string data is in XML, see the \l{XML Processing} overview.

	\annotatedlist string-processing

    \section1 Information about Unicode on the Web

    The \l{http://www.unicode.org/}{Unicode Consortium} has a number
    of documents available, including

    \list

    \li The current version of the standard: \l{http://www.unicode.org/versions/Unicode6.2.0/}{Unicode 6.2.0}.
    \li \l{http://www.unicode.org/unicode/standard/principles.html}{A
    technical introduction to Unicode}
    \li \l{http://www.unicode.org/unicode/standard/standard.html}{The
    home page for the standard}

    \endlist

    \section1 Unicode in Qt

    In Qt, and in most applications that use Qt, most or all user-visible
    strings are stored using Unicode. Qt provides:

    \list

    \li Translation to/from legacy encodings for file I/O: see
    QTextCodec and QTextStream.
    \li Support for locale specific Input Methods and keyboards.
    \li A string class, QString, that stores Unicode characters, with
    support for migrating from C strings including fast
    translation to and from UTF-8, ISO8859-1 and US-ASCII, and all the
    usual string operations.
    \li Unicode-aware UI controls.
    \li Unicode compliant text segmentation (QTextBoundaryFinder)
    \li Unicode compliant line breaking and text rendering

    \endlist

    To fully benefit from Unicode, we recommend using QString for storing
    all user-visible strings, and performing all text file I/O using
    QTextStream.

    All the function arguments in Qt that may be user-visible strings,
    QLabel::setText() and a many others, take \c{const QString &}s.
    QString provides implicit casting from \c{const char *}
    so that things like

    \snippet doc/src/snippets/code/doc_src_unicode.cpp 0

    will work. There is also a function, QObject::tr(), that provides
    translation support, like this:

    \snippet doc/src/snippets/code/doc_src_unicode.cpp 1

    QObject::tr() maps from \c{const char *} to a Unicode string, and
    uses installable QTranslator objects to do the mapping.

    Qt provides a number of built-in QTextCodec 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.

    Conversion to/from \c{const char *} uses a UTF-8.
    However, applications can easily find codecs
    for other locales, and set any open file or network connection to use
    a special codec.

    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:

    \snippet doc/src/snippets/code/doc_src_unicode.cpp 2

    or

    \snippet doc/src/snippets/code/doc_src_unicode.cpp 3

    Qt supports rendering text in most languages written in the world. The detailed
    list of supported writing systems depends a bit on operating system support and
    font availability on the target system.

    \sa {Internationalization with Qt}
*/