1<!-- doc/src/sgml/charset.sgml -->
2
3<chapter id="charset">
4 <title>Localization</title>
5
6 <para>
7  This chapter describes the available localization features from the
8  point of view of the administrator.
9  <productname>PostgreSQL</productname> supports two localization
10  facilities:
11
12   <itemizedlist>
13    <listitem>
14     <para>
15      Using the locale features of the operating system to provide
16      locale-specific collation order, number formatting, translated
17      messages, and other aspects.
18      This is covered in <xref linkend="locale"/> and
19      <xref linkend="collation"/>.
20     </para>
21    </listitem>
22
23    <listitem>
24     <para>
25      Providing a number of different character sets to support storing text
26      in all kinds of languages, and providing character set translation
27      between client and server.
28      This is covered in <xref linkend="multibyte"/>.
29     </para>
30    </listitem>
31   </itemizedlist>
32  </para>
33
34
35 <sect1 id="locale">
36  <title>Locale Support</title>
37
38  <indexterm zone="locale"><primary>locale</primary></indexterm>
39
40  <para>
41   <firstterm>Locale</firstterm> support refers to an application respecting
42   cultural preferences regarding alphabets, sorting, number
43   formatting, etc.  <productname>PostgreSQL</productname> uses the standard ISO
44   C and <acronym>POSIX</acronym> locale facilities provided by the server operating
45   system.  For additional information refer to the documentation of your
46   system.
47  </para>
48
49  <sect2>
50   <title>Overview</title>
51
52   <para>
53    Locale support is automatically initialized when a database
54    cluster is created using <command>initdb</command>.
55    <command>initdb</command> will initialize the database cluster
56    with the locale setting of its execution environment by default,
57    so if your system is already set to use the locale that you want
58    in your database cluster then there is nothing else you need to
59    do.  If you want to use a different locale (or you are not sure
60    which locale your system is set to), you can instruct
61    <command>initdb</command> exactly which locale to use by
62    specifying the <option>--locale</option> option. For example:
63<screen>
64initdb --locale=sv_SE
65</screen>
66   </para>
67
68   <para>
69    This example for Unix systems sets the locale to Swedish
70    (<literal>sv</literal>) as spoken
71    in Sweden (<literal>SE</literal>).  Other possibilities might include
72    <literal>en_US</literal> (U.S. English) and <literal>fr_CA</literal> (French
73    Canadian).  If more than one character set can be used for a
74    locale then the specifications can take the form
75    <replaceable>language_territory.codeset</replaceable>.  For example,
76    <literal>fr_BE.UTF-8</literal> represents the French language (fr) as
77    spoken in Belgium (BE), with a <acronym>UTF-8</acronym> character set
78    encoding.
79   </para>
80
81   <para>
82    What locales are available on your
83    system under what names depends on what was provided by the operating
84    system vendor and what was installed.  On most Unix systems, the command
85    <literal>locale -a</literal> will provide a list of available locales.
86    Windows uses more verbose locale names, such as <literal>German_Germany</literal>
87    or <literal>Swedish_Sweden.1252</literal>, but the principles are the same.
88   </para>
89
90   <para>
91    Occasionally it is useful to mix rules from several locales, e.g.,
92    use English collation rules but Spanish messages.  To support that, a
93    set of locale subcategories exist that control only certain
94    aspects of the localization rules:
95
96    <informaltable>
97     <tgroup cols="2">
98      <colspec colname="col1" colwidth="1*"/>
99      <colspec colname="col2" colwidth="3*"/>
100      <tbody>
101       <row>
102        <entry><envar>LC_COLLATE</envar></entry>
103        <entry>String sort order</entry>
104       </row>
105       <row>
106        <entry><envar>LC_CTYPE</envar></entry>
107        <entry>Character classification (What is a letter? Its upper-case equivalent?)</entry>
108       </row>
109       <row>
110        <entry><envar>LC_MESSAGES</envar></entry>
111        <entry>Language of messages</entry>
112       </row>
113       <row>
114        <entry><envar>LC_MONETARY</envar></entry>
115        <entry>Formatting of currency amounts</entry>
116       </row>
117       <row>
118        <entry><envar>LC_NUMERIC</envar></entry>
119        <entry>Formatting of numbers</entry>
120       </row>
121       <row>
122        <entry><envar>LC_TIME</envar></entry>
123        <entry>Formatting of dates and times</entry>
124       </row>
125      </tbody>
126     </tgroup>
127    </informaltable>
128
129    The category names translate into names of
130    <command>initdb</command> options to override the locale choice
131    for a specific category.  For instance, to set the locale to
132    French Canadian, but use U.S. rules for formatting currency, use
133    <literal>initdb --locale=fr_CA --lc-monetary=en_US</literal>.
134   </para>
135
136   <para>
137    If you want the system to behave as if it had no locale support,
138    use the special locale name <literal>C</literal>, or equivalently
139    <literal>POSIX</literal>.
140   </para>
141
142   <para>
143    Some locale categories must have their values
144    fixed when the database is created.  You can use different settings
145    for different databases, but once a database is created, you cannot
146    change them for that database anymore. <literal>LC_COLLATE</literal>
147    and <literal>LC_CTYPE</literal> are these categories.  They affect
148    the sort order of indexes, so they must be kept fixed, or indexes on
149    text columns would become corrupt.
150    (But you can alleviate this restriction using collations, as discussed
151    in <xref linkend="collation"/>.)
152    The default values for these
153    categories are determined when <command>initdb</command> is run, and
154    those values are used when new databases are created, unless
155    specified otherwise in the <command>CREATE DATABASE</command> command.
156   </para>
157
158   <para>
159    The other locale categories can be changed whenever desired
160    by setting the server configuration parameters
161    that have the same name as the locale categories (see <xref
162    linkend="runtime-config-client-format"/> for details).  The values
163    that are chosen by <command>initdb</command> are actually only written
164    into the configuration file <filename>postgresql.conf</filename> to
165    serve as defaults when the server is started.  If you remove these
166    assignments from <filename>postgresql.conf</filename> then the
167    server will inherit the settings from its execution environment.
168   </para>
169
170   <para>
171    Note that the locale behavior of the server is determined by the
172    environment variables seen by the server, not by the environment
173    of any client.  Therefore, be careful to configure the correct locale settings
174    before starting the server.  A consequence of this is that if
175    client and server are set up in different locales, messages might
176    appear in different languages depending on where they originated.
177   </para>
178
179   <note>
180    <para>
181     When we speak of inheriting the locale from the execution
182     environment, this means the following on most operating systems:
183     For a given locale category, say the collation, the following
184     environment variables are consulted in this order until one is
185     found to be set: <envar>LC_ALL</envar>, <envar>LC_COLLATE</envar>
186     (or the variable corresponding to the respective category),
187     <envar>LANG</envar>.  If none of these environment variables are
188     set then the locale defaults to <literal>C</literal>.
189    </para>
190
191    <para>
192     Some message localization libraries also look at the environment
193     variable <envar>LANGUAGE</envar> which overrides all other locale
194     settings for the purpose of setting the language of messages.  If
195     in doubt, please refer to the documentation of your operating
196     system, in particular the documentation about
197     <application>gettext</application>.
198    </para>
199   </note>
200
201   <para>
202    To enable messages to be translated to the user's preferred language,
203    <acronym>NLS</acronym> must have been selected at build time
204    (<literal>configure --enable-nls</literal>).  All other locale support is
205    built in automatically.
206   </para>
207  </sect2>
208
209  <sect2>
210   <title>Behavior</title>
211
212   <para>
213    The locale settings influence the following SQL features:
214
215    <itemizedlist>
216     <listitem>
217      <para>
218       Sort order in queries using <literal>ORDER BY</literal> or the standard
219       comparison operators on textual data
220       <indexterm><primary>ORDER BY</primary><secondary>and locales</secondary></indexterm>
221      </para>
222     </listitem>
223
224     <listitem>
225      <para>
226       The <function>upper</function>, <function>lower</function>, and <function>initcap</function>
227       functions
228       <indexterm><primary>upper</primary><secondary>and locales</secondary></indexterm>
229       <indexterm><primary>lower</primary><secondary>and locales</secondary></indexterm>
230      </para>
231     </listitem>
232
233     <listitem>
234      <para>
235       Pattern matching operators (<literal>LIKE</literal>, <literal>SIMILAR TO</literal>,
236       and POSIX-style regular expressions); locales affect both case
237       insensitive matching and the classification of characters by
238       character-class regular expressions
239       <indexterm><primary>LIKE</primary><secondary>and locales</secondary></indexterm>
240       <indexterm><primary>regular expressions</primary><secondary>and locales</secondary></indexterm>
241      </para>
242     </listitem>
243
244     <listitem>
245      <para>
246       The <function>to_char</function> family of functions
247       <indexterm><primary>to_char</primary><secondary>and locales</secondary></indexterm>
248      </para>
249     </listitem>
250
251     <listitem>
252      <para>
253       The ability to use indexes with <literal>LIKE</literal> clauses
254      </para>
255     </listitem>
256    </itemizedlist>
257   </para>
258
259   <para>
260    The drawback of using locales other than <literal>C</literal> or
261    <literal>POSIX</literal> in <productname>PostgreSQL</productname> is its performance
262    impact. It slows character handling and prevents ordinary indexes
263    from being used by <literal>LIKE</literal>. For this reason use locales
264    only if you actually need them.
265   </para>
266
267   <para>
268    As a workaround to allow <productname>PostgreSQL</productname> to use indexes
269    with <literal>LIKE</literal> clauses under a non-C locale, several custom
270    operator classes exist. These allow the creation of an index that
271    performs a strict character-by-character comparison, ignoring
272    locale comparison rules. Refer to <xref linkend="indexes-opclass"/>
273    for more information.  Another approach is to create indexes using
274    the <literal>C</literal> collation, as discussed in
275    <xref linkend="collation"/>.
276   </para>
277  </sect2>
278
279  <sect2>
280   <title>Problems</title>
281
282   <para>
283    If locale support doesn't work according to the explanation above,
284    check that the locale support in your operating system is
285    correctly configured.  To check what locales are installed on your
286    system, you can use the command <literal>locale -a</literal> if
287    your operating system provides it.
288   </para>
289
290   <para>
291    Check that <productname>PostgreSQL</productname> is actually using the locale
292    that you think it is.  The <envar>LC_COLLATE</envar> and <envar>LC_CTYPE</envar>
293    settings are determined when a database is created, and cannot be
294    changed except by creating a new database.  Other locale
295    settings including <envar>LC_MESSAGES</envar> and <envar>LC_MONETARY</envar>
296    are initially determined by the environment the server is started
297    in, but can be changed on-the-fly.  You can check the active locale
298    settings using the <command>SHOW</command> command.
299   </para>
300
301   <para>
302    The directory <filename>src/test/locale</filename> in the source
303    distribution contains a test suite for
304    <productname>PostgreSQL</productname>'s locale support.
305   </para>
306
307   <para>
308    Client applications that handle server-side errors by parsing the
309    text of the error message will obviously have problems when the
310    server's messages are in a different language.  Authors of such
311    applications are advised to make use of the error code scheme
312    instead.
313   </para>
314
315   <para>
316    Maintaining catalogs of message translations requires the on-going
317    efforts of many volunteers that want to see
318    <productname>PostgreSQL</productname> speak their preferred language well.
319    If messages in your language are currently not available or not fully
320    translated, your assistance would be appreciated.  If you want to
321    help, refer to <xref linkend="nls"/> or write to the developers'
322    mailing list.
323   </para>
324  </sect2>
325 </sect1>
326
327
328 <sect1 id="collation">
329  <title>Collation Support</title>
330
331  <indexterm zone="collation"><primary>collation</primary></indexterm>
332
333  <para>
334   The collation feature allows specifying the sort order and character
335   classification behavior of data per-column, or even per-operation.
336   This alleviates the restriction that the
337   <symbol>LC_COLLATE</symbol> and <symbol>LC_CTYPE</symbol> settings
338   of a database cannot be changed after its creation.
339  </para>
340
341  <sect2>
342   <title>Concepts</title>
343
344   <para>
345    Conceptually, every expression of a collatable data type has a
346    collation.  (The built-in collatable data types are
347    <type>text</type>, <type>varchar</type>, and <type>char</type>.
348    User-defined base types can also be marked collatable, and of course
349    a domain over a collatable data type is collatable.)  If the
350    expression is a column reference, the collation of the expression is the
351    defined collation of the column.  If the expression is a constant, the
352    collation is the default collation of the data type of the
353    constant.  The collation of a more complex expression is derived
354    from the collations of its inputs, as described below.
355   </para>
356
357   <para>
358    The collation of an expression can be the <quote>default</quote>
359    collation, which means the locale settings defined for the
360    database.  It is also possible for an expression's collation to be
361    indeterminate.  In such cases, ordering operations and other
362    operations that need to know the collation will fail.
363   </para>
364
365   <para>
366    When the database system has to perform an ordering or a character
367    classification, it uses the collation of the input expression.  This
368    happens, for example, with <literal>ORDER BY</literal> clauses
369    and function or operator calls such as <literal>&lt;</literal>.
370    The collation to apply for an <literal>ORDER BY</literal> clause
371    is simply the collation of the sort key.  The collation to apply for a
372    function or operator call is derived from the arguments, as described
373    below.  In addition to comparison operators, collations are taken into
374    account by functions that convert between lower and upper case
375    letters, such as <function>lower</function>, <function>upper</function>, and
376    <function>initcap</function>; by pattern matching operators; and by
377    <function>to_char</function> and related functions.
378   </para>
379
380   <para>
381    For a function or operator call, the collation that is derived by
382    examining the argument collations is used at run time for performing
383    the specified operation.  If the result of the function or operator
384    call is of a collatable data type, the collation is also used at parse
385    time as the defined collation of the function or operator expression,
386    in case there is a surrounding expression that requires knowledge of
387    its collation.
388   </para>
389
390   <para>
391    The <firstterm>collation derivation</firstterm> of an expression can be
392    implicit or explicit.  This distinction affects how collations are
393    combined when multiple different collations appear in an
394    expression.  An explicit collation derivation occurs when a
395    <literal>COLLATE</literal> clause is used; all other collation
396    derivations are implicit.  When multiple collations need to be
397    combined, for example in a function call, the following rules are
398    used:
399
400    <orderedlist>
401     <listitem>
402      <para>
403       If any input expression has an explicit collation derivation, then
404       all explicitly derived collations among the input expressions must be
405       the same, otherwise an error is raised.  If any explicitly
406       derived collation is present, that is the result of the
407       collation combination.
408      </para>
409     </listitem>
410
411     <listitem>
412      <para>
413       Otherwise, all input expressions must have the same implicit
414       collation derivation or the default collation.  If any non-default
415       collation is present, that is the result of the collation combination.
416       Otherwise, the result is the default collation.
417      </para>
418     </listitem>
419
420     <listitem>
421      <para>
422       If there are conflicting non-default implicit collations among the
423       input expressions, then the combination is deemed to have indeterminate
424       collation.  This is not an error condition unless the particular
425       function being invoked requires knowledge of the collation it should
426       apply.  If it does, an error will be raised at run-time.
427      </para>
428     </listitem>
429    </orderedlist>
430
431    For example, consider this table definition:
432<programlisting>
433CREATE TABLE test1 (
434    a text COLLATE "de_DE",
435    b text COLLATE "es_ES",
436    ...
437);
438</programlisting>
439
440    Then in
441<programlisting>
442SELECT a &lt; 'foo' FROM test1;
443</programlisting>
444    the <literal>&lt;</literal> comparison is performed according to
445    <literal>de_DE</literal> rules, because the expression combines an
446    implicitly derived collation with the default collation.  But in
447<programlisting>
448SELECT a &lt; ('foo' COLLATE "fr_FR") FROM test1;
449</programlisting>
450    the comparison is performed using <literal>fr_FR</literal> rules,
451    because the explicit collation derivation overrides the implicit one.
452    Furthermore, given
453<programlisting>
454SELECT a &lt; b FROM test1;
455</programlisting>
456    the parser cannot determine which collation to apply, since the
457    <structfield>a</structfield> and <structfield>b</structfield> columns have conflicting
458    implicit collations.  Since the <literal>&lt;</literal> operator
459    does need to know which collation to use, this will result in an
460    error.  The error can be resolved by attaching an explicit collation
461    specifier to either input expression, thus:
462<programlisting>
463SELECT a &lt; b COLLATE "de_DE" FROM test1;
464</programlisting>
465    or equivalently
466<programlisting>
467SELECT a COLLATE "de_DE" &lt; b FROM test1;
468</programlisting>
469    On the other hand, the structurally similar case
470<programlisting>
471SELECT a || b FROM test1;
472</programlisting>
473    does not result in an error, because the <literal>||</literal> operator
474    does not care about collations: its result is the same regardless
475    of the collation.
476   </para>
477
478   <para>
479    The collation assigned to a function or operator's combined input
480    expressions is also considered to apply to the function or operator's
481    result, if the function or operator delivers a result of a collatable
482    data type.  So, in
483<programlisting>
484SELECT * FROM test1 ORDER BY a || 'foo';
485</programlisting>
486    the ordering will be done according to <literal>de_DE</literal> rules.
487    But this query:
488<programlisting>
489SELECT * FROM test1 ORDER BY a || b;
490</programlisting>
491    results in an error, because even though the <literal>||</literal> operator
492    doesn't need to know a collation, the <literal>ORDER BY</literal> clause does.
493    As before, the conflict can be resolved with an explicit collation
494    specifier:
495<programlisting>
496SELECT * FROM test1 ORDER BY a || b COLLATE "fr_FR";
497</programlisting>
498   </para>
499  </sect2>
500
501  <sect2 id="collation-managing">
502   <title>Managing Collations</title>
503
504   <para>
505    A collation is an SQL schema object that maps an SQL name to locales
506    provided by libraries installed in the operating system.  A collation
507    definition has a <firstterm>provider</firstterm> that specifies which
508    library supplies the locale data.  One standard provider name
509    is <literal>libc</literal>, which uses the locales provided by the
510    operating system C library.  These are the locales that most tools
511    provided by the operating system use.  Another provider
512    is <literal>icu</literal>, which uses the external
513    ICU<indexterm><primary>ICU</primary></indexterm> library.  ICU locales can only be
514    used if support for ICU was configured when PostgreSQL was built.
515   </para>
516
517   <para>
518    A collation object provided by <literal>libc</literal> maps to a
519    combination of <symbol>LC_COLLATE</symbol> and <symbol>LC_CTYPE</symbol>
520    settings, as accepted by the <literal>setlocale()</literal> system library call.  (As
521    the name would suggest, the main purpose of a collation is to set
522    <symbol>LC_COLLATE</symbol>, which controls the sort order.  But
523    it is rarely necessary in practice to have an
524    <symbol>LC_CTYPE</symbol> setting that is different from
525    <symbol>LC_COLLATE</symbol>, so it is more convenient to collect
526    these under one concept than to create another infrastructure for
527    setting <symbol>LC_CTYPE</symbol> per expression.)  Also,
528    a <literal>libc</literal> collation
529    is tied to a character set encoding (see <xref linkend="multibyte"/>).
530    The same collation name may exist for different encodings.
531   </para>
532
533   <para>
534    A collation object provided by <literal>icu</literal> maps to a named
535    collator provided by the ICU library.  ICU does not support
536    separate <quote>collate</quote> and <quote>ctype</quote> settings, so
537    they are always the same.  Also, ICU collations are independent of the
538    encoding, so there is always only one ICU collation of a given name in
539    a database.
540   </para>
541
542   <sect3>
543    <title>Standard Collations</title>
544
545   <para>
546    On all platforms, the collations named <literal>default</literal>,
547    <literal>C</literal>, and <literal>POSIX</literal> are available.  Additional
548    collations may be available depending on operating system support.
549    The <literal>default</literal> collation selects the <symbol>LC_COLLATE</symbol>
550    and <symbol>LC_CTYPE</symbol> values specified at database creation time.
551    The <literal>C</literal> and <literal>POSIX</literal> collations both specify
552    <quote>traditional C</quote> behavior, in which only the ASCII letters
553    <quote><literal>A</literal></quote> through <quote><literal>Z</literal></quote>
554    are treated as letters, and sorting is done strictly by character
555    code byte values.
556   </para>
557
558   <para>
559    Additionally, the SQL standard collation name <literal>ucs_basic</literal>
560    is available for encoding <literal>UTF8</literal>.  It is equivalent
561    to <literal>C</literal> and sorts by Unicode code point.
562   </para>
563  </sect3>
564
565  <sect3>
566   <title>Predefined Collations</title>
567
568   <para>
569    If the operating system provides support for using multiple locales
570    within a single program (<function>newlocale</function> and related functions),
571    or if support for ICU is configured,
572    then when a database cluster is initialized, <command>initdb</command>
573    populates the system catalog <literal>pg_collation</literal> with
574    collations based on all the locales it finds in the operating
575    system at the time.
576   </para>
577
578   <para>
579    To inspect the currently available locales, use the query <literal>SELECT
580    * FROM pg_collation</literal>, or the command <command>\dOS+</command>
581    in <application>psql</application>.
582   </para>
583
584  <sect4>
585   <title>libc Collations</title>
586
587   <para>
588    For example, the operating system might
589    provide a locale named <literal>de_DE.utf8</literal>.
590    <command>initdb</command> would then create a collation named
591    <literal>de_DE.utf8</literal> for encoding <literal>UTF8</literal>
592    that has both <symbol>LC_COLLATE</symbol> and
593    <symbol>LC_CTYPE</symbol> set to <literal>de_DE.utf8</literal>.
594    It will also create a collation with the <literal>.utf8</literal>
595    tag stripped off the name.  So you could also use the collation
596    under the name <literal>de_DE</literal>, which is less cumbersome
597    to write and makes the name less encoding-dependent.  Note that,
598    nevertheless, the initial set of collation names is
599    platform-dependent.
600   </para>
601
602   <para>
603    The default set of collations provided by <literal>libc</literal> map
604    directly to the locales installed in the operating system, which can be
605    listed using the command <literal>locale -a</literal>.  In case
606    a <literal>libc</literal> collation is needed that has different values
607    for <symbol>LC_COLLATE</symbol> and <symbol>LC_CTYPE</symbol>, or if new
608    locales are installed in the operating system after the database system
609    was initialized, then a new collation may be created using
610    the <xref linkend="sql-createcollation"/> command.
611    New operating system locales can also be imported en masse using
612    the <link linkend="functions-admin-collation"><function>pg_import_system_collations()</function></link> function.
613   </para>
614
615   <para>
616    Within any particular database, only collations that use that
617    database's encoding are of interest.  Other entries in
618    <literal>pg_collation</literal> are ignored.  Thus, a stripped collation
619    name such as <literal>de_DE</literal> can be considered unique
620    within a given database even though it would not be unique globally.
621    Use of the stripped collation names is recommended, since it will
622    make one fewer thing you need to change if you decide to change to
623    another database encoding.  Note however that the <literal>default</literal>,
624    <literal>C</literal>, and <literal>POSIX</literal> collations can be used regardless of
625    the database encoding.
626   </para>
627
628   <para>
629    <productname>PostgreSQL</productname> considers distinct collation
630    objects to be incompatible even when they have identical properties.
631    Thus for example,
632<programlisting>
633SELECT a COLLATE "C" &lt; b COLLATE "POSIX" FROM test1;
634</programlisting>
635    will draw an error even though the <literal>C</literal> and <literal>POSIX</literal>
636    collations have identical behaviors.  Mixing stripped and non-stripped
637    collation names is therefore not recommended.
638   </para>
639  </sect4>
640
641  <sect4>
642   <title>ICU Collations</title>
643
644   <para>
645    With ICU, it is not sensible to enumerate all possible locale names.  ICU
646    uses a particular naming system for locales, but there are many more ways
647    to name a locale than there are actually distinct locales.
648    <command>initdb</command> uses the ICU APIs to extract a set of distinct
649    locales to populate the initial set of collations.  Collations provided by
650    ICU are created in the SQL environment with names in BCP 47 language tag
651    format, with a <quote>private use</quote>
652    extension <literal>-x-icu</literal> appended, to distinguish them from
653    libc locales.
654   </para>
655
656   <para>
657    Here are some example collations that might be created:
658
659    <variablelist>
660     <varlistentry>
661      <term><literal>de-x-icu</literal></term>
662      <listitem>
663       <para>German collation, default variant</para>
664      </listitem>
665     </varlistentry>
666
667     <varlistentry>
668      <term><literal>de-AT-x-icu</literal></term>
669      <listitem>
670       <para>German collation for Austria, default variant</para>
671       <para>
672        (There are also, say, <literal>de-DE-x-icu</literal>
673        or <literal>de-CH-x-icu</literal>, but as of this writing, they are
674        equivalent to <literal>de-x-icu</literal>.)
675       </para>
676      </listitem>
677     </varlistentry>
678
679     <varlistentry>
680      <term><literal>und-x-icu</literal> (for <quote>undefined</quote>)</term>
681      <listitem>
682       <para>
683        ICU <quote>root</quote> collation.  Use this to get a reasonable
684        language-agnostic sort order.
685       </para>
686      </listitem>
687     </varlistentry>
688    </variablelist>
689   </para>
690
691   <para>
692    Some (less frequently used) encodings are not supported by ICU.  When the
693    database encoding is one of these, ICU collation entries
694    in <literal>pg_collation</literal> are ignored.  Attempting to use one
695    will draw an error along the lines of <quote>collation "de-x-icu" for
696    encoding "WIN874" does not exist</quote>.
697   </para>
698  </sect4>
699  </sect3>
700
701  <sect3 id="collation-create">
702   <title>Creating New Collation Objects</title>
703
704   <para>
705    If the standard and predefined collations are not sufficient, users can
706    create their own collation objects using the SQL
707    command <xref linkend="sql-createcollation"/>.
708   </para>
709
710   <para>
711    The standard and predefined collations are in the
712    schema <literal>pg_catalog</literal>, like all predefined objects.
713    User-defined collations should be created in user schemas.  This also
714    ensures that they are saved by <command>pg_dump</command>.
715   </para>
716
717   <sect4>
718    <title>libc Collations</title>
719
720    <para>
721     New libc collations can be created like this:
722<programlisting>
723CREATE COLLATION german (provider = libc, locale = 'de_DE');
724</programlisting>
725     The exact values that are acceptable for the <literal>locale</literal>
726     clause in this command depend on the operating system.  On Unix-like
727     systems, the command <literal>locale -a</literal> will show a list.
728    </para>
729
730    <para>
731     Since the predefined libc collations already include all collations
732     defined in the operating system when the database instance is
733     initialized, it is not often necessary to manually create new ones.
734     Reasons might be if a different naming system is desired (in which case
735     see also <xref linkend="collation-copy"/>) or if the operating system has
736     been upgraded to provide new locale definitions (in which case see
737     also <link linkend="functions-admin-collation"><function>pg_import_system_collations()</function></link>).
738    </para>
739   </sect4>
740
741   <sect4>
742    <title>ICU Collations</title>
743
744   <para>
745    ICU allows collations to be customized beyond the basic language+country
746    set that is preloaded by <command>initdb</command>.  Users are encouraged
747    to define their own collation objects that make use of these facilities to
748    suit the sorting behavior to their requirements.
749    See <ulink url="https://unicode-org.github.io/icu/userguide/locale/"></ulink>
750    and <ulink url="https://unicode-org.github.io/icu/userguide/collation/api.html"></ulink> for
751    information on ICU locale naming.  The set of acceptable names and
752    attributes depends on the particular ICU version.
753   </para>
754
755   <para>
756    Here are some examples:
757
758    <variablelist>
759     <varlistentry>
760      <term><literal>CREATE COLLATION "de-u-co-phonebk-x-icu" (provider = icu, locale = 'de-u-co-phonebk');</literal></term>
761      <term><literal>CREATE COLLATION "de-u-co-phonebk-x-icu" (provider = icu, locale = 'de@collation=phonebook');</literal></term>
762      <listitem>
763       <para>German collation with phone book collation type</para>
764       <para>
765        The first example selects the ICU locale using a <quote>language
766        tag</quote> per BCP 47.  The second example uses the traditional
767        ICU-specific locale syntax.  The first style is preferred going
768        forward, but it is not supported by older ICU versions.
769       </para>
770       <para>
771        Note that you can name the collation objects in the SQL environment
772        anything you want.  In this example, we follow the naming style that
773        the predefined collations use, which in turn also follow BCP 47, but
774        that is not required for user-defined collations.
775       </para>
776      </listitem>
777     </varlistentry>
778
779     <varlistentry>
780      <term><literal>CREATE COLLATION "und-u-co-emoji-x-icu" (provider = icu, locale = 'und-u-co-emoji');</literal></term>
781      <term><literal>CREATE COLLATION "und-u-co-emoji-x-icu" (provider = icu, locale = '@collation=emoji');</literal></term>
782      <listitem>
783       <para>
784        Root collation with Emoji collation type, per Unicode Technical Standard #51
785       </para>
786       <para>
787        Observe how in the traditional ICU locale naming system, the root
788        locale is selected by an empty string.
789       </para>
790      </listitem>
791     </varlistentry>
792
793     <varlistentry>
794      <term><literal>CREATE COLLATION latinlast (provider = icu, locale = 'en-u-kr-grek-latn');</literal></term>
795      <term><literal>CREATE COLLATION latinlast (provider = icu, locale = 'en@colReorder=grek-latn');</literal></term>
796      <listitem>
797       <para>
798        Sort Greek letters before Latin ones.  (The default is Latin before Greek.)
799       </para>
800      </listitem>
801     </varlistentry>
802
803     <varlistentry>
804      <term><literal>CREATE COLLATION upperfirst (provider = icu, locale = 'en-u-kf-upper');</literal></term>
805      <term><literal>CREATE COLLATION upperfirst (provider = icu, locale = 'en@colCaseFirst=upper');</literal></term>
806      <listitem>
807       <para>
808        Sort upper-case letters before lower-case letters.  (The default is
809        lower-case letters first.)
810       </para>
811      </listitem>
812     </varlistentry>
813
814    <varlistentry>
815      <term><literal>CREATE COLLATION special (provider = icu, locale = 'en-u-kf-upper-kr-grek-latn');</literal></term>
816      <term><literal>CREATE COLLATION special (provider = icu, locale = 'en@colCaseFirst=upper;colReorder=grek-latn');</literal></term>
817      <listitem>
818       <para>
819        Combines both of the above options.
820       </para>
821      </listitem>
822     </varlistentry>
823
824     <varlistentry>
825      <term><literal>CREATE COLLATION numeric (provider = icu, locale = 'en-u-kn-true');</literal></term>
826      <term><literal>CREATE COLLATION numeric (provider = icu, locale = 'en@colNumeric=yes');</literal></term>
827      <listitem>
828       <para>
829        Numeric ordering, sorts sequences of digits by their numeric value,
830        for example: <literal>A-21</literal> &lt; <literal>A-123</literal>
831        (also known as natural sort).
832       </para>
833      </listitem>
834     </varlistentry>
835    </variablelist>
836
837    See <ulink url="https://www.unicode.org/reports/tr35/tr35-collation.html">Unicode
838    Technical Standard #35</ulink>
839    and <ulink url="https://tools.ietf.org/html/bcp47">BCP 47</ulink> for
840    details.  The list of possible collation types (<literal>co</literal>
841    subtag) can be found in
842    the <ulink url="https://github.com/unicode-org/cldr/blob/master/common/bcp47/collation.xml">CLDR
843    repository</ulink>.
844   </para>
845
846   <para>
847    Note that while this system allows creating collations that <quote>ignore
848    case</quote> or <quote>ignore accents</quote> or similar (using the
849    <literal>ks</literal> key), in order for such collations to act in a
850    truly case- or accent-insensitive manner, they also need to be declared as not
851    <firstterm>deterministic</firstterm> in <command>CREATE COLLATION</command>;
852    see <xref linkend="collation-nondeterministic"/>.
853    Otherwise, any strings that compare equal according to the collation but
854    are not byte-wise equal will be sorted according to their byte values.
855   </para>
856
857   <note>
858    <para>
859     By design, ICU will accept almost any string as a locale name and match
860     it to the closest locale it can provide, using the fallback procedure
861     described in its documentation.  Thus, there will be no direct feedback
862     if a collation specification is composed using features that the given
863     ICU installation does not actually support.  It is therefore recommended
864     to create application-level test cases to check that the collation
865     definitions satisfy one's requirements.
866    </para>
867   </note>
868   </sect4>
869
870   <sect4 id="collation-copy">
871   <title>Copying Collations</title>
872
873   <para>
874    The command <xref linkend="sql-createcollation"/> can also be used to
875    create a new collation from an existing collation, which can be useful to
876    be able to use operating-system-independent collation names in
877    applications, create compatibility names, or use an ICU-provided collation
878    under a more readable name.  For example:
879<programlisting>
880CREATE COLLATION german FROM "de_DE";
881CREATE COLLATION french FROM "fr-x-icu";
882</programlisting>
883   </para>
884   </sect4>
885   </sect3>
886
887   <sect3 id="collation-nondeterministic">
888    <title>Nondeterministic Collations</title>
889
890    <para>
891     A collation is either <firstterm>deterministic</firstterm> or
892     <firstterm>nondeterministic</firstterm>.  A deterministic collation uses
893     deterministic comparisons, which means that it considers strings to be
894     equal only if they consist of the same byte sequence.  Nondeterministic
895     comparison may determine strings to be equal even if they consist of
896     different bytes.  Typical situations include case-insensitive comparison,
897     accent-insensitive comparison, as well as comparison of strings in
898     different Unicode normal forms.  It is up to the collation provider to
899     actually implement such insensitive comparisons; the deterministic flag
900     only determines whether ties are to be broken using bytewise comparison.
901     See also <ulink url="https://www.unicode.org/reports/tr10">Unicode Technical
902     Standard 10</ulink> for more information on the terminology.
903    </para>
904
905    <para>
906     To create a nondeterministic collation, specify the property
907     <literal>deterministic = false</literal> to <command>CREATE
908     COLLATION</command>, for example:
909<programlisting>
910CREATE COLLATION ndcoll (provider = icu, locale = 'und', deterministic = false);
911</programlisting>
912     This example would use the standard Unicode collation in a
913     nondeterministic way.  In particular, this would allow strings in
914     different normal forms to be compared correctly.  More interesting
915     examples make use of the ICU customization facilities explained above.
916     For example:
917<programlisting>
918CREATE COLLATION case_insensitive (provider = icu, locale = 'und-u-ks-level2', deterministic = false);
919CREATE COLLATION ignore_accents (provider = icu, locale = 'und-u-ks-level1-kc-true', deterministic = false);
920</programlisting>
921    </para>
922
923    <para>
924     All standard and predefined collations are deterministic, all
925     user-defined collations are deterministic by default.  While
926     nondeterministic collations give a more <quote>correct</quote> behavior,
927     especially when considering the full power of Unicode and its many
928     special cases, they also have some drawbacks.  Foremost, their use leads
929     to a performance penalty.  Note, in particular, that B-tree cannot use
930     deduplication with indexes that use a nondeterministic collation.  Also,
931     certain operations are not possible with nondeterministic collations,
932     such as pattern matching operations.  Therefore, they should be used
933     only in cases where they are specifically wanted.
934    </para>
935
936    <tip>
937     <para>
938      To deal with text in different Unicode normalization forms, it is also
939      an option to use the functions/expressions
940      <function>normalize</function> and <literal>is normalized</literal> to
941      preprocess or check the strings, instead of using nondeterministic
942      collations.  There are different trade-offs for each approach.
943     </para>
944    </tip>
945   </sect3>
946  </sect2>
947 </sect1>
948
949 <sect1 id="multibyte">
950  <title>Character Set Support</title>
951
952  <indexterm zone="multibyte"><primary>character set</primary></indexterm>
953
954  <para>
955   The character set support in <productname>PostgreSQL</productname>
956   allows you to store text in a variety of character sets (also called
957   encodings), including
958   single-byte character sets such as the ISO 8859 series and
959   multiple-byte character sets such as <acronym>EUC</acronym> (Extended Unix
960   Code), UTF-8, and Mule internal code.  All supported character sets
961   can be used transparently by clients, but a few are not supported
962   for use within the server (that is, as a server-side encoding).
963   The default character set is selected while
964   initializing your <productname>PostgreSQL</productname> database
965   cluster using <command>initdb</command>.  It can be overridden when you
966   create a database, so you can have multiple
967   databases each with a different character set.
968  </para>
969
970  <para>
971   An important restriction, however, is that each database's character set
972   must be compatible with the database's <envar>LC_CTYPE</envar> (character
973   classification) and <envar>LC_COLLATE</envar> (string sort order) locale
974   settings. For <literal>C</literal> or
975   <literal>POSIX</literal> locale, any character set is allowed, but for other
976   libc-provided locales there is only one character set that will work
977   correctly.
978   (On Windows, however, UTF-8 encoding can be used with any locale.)
979   If you have ICU support configured, ICU-provided locales can be used
980   with most but not all server-side encodings.
981  </para>
982
983   <sect2 id="multibyte-charset-supported">
984    <title>Supported Character Sets</title>
985
986    <para>
987     <xref linkend="charset-table"/> shows the character sets available
988     for use in <productname>PostgreSQL</productname>.
989    </para>
990
991     <table id="charset-table">
992      <title><productname>PostgreSQL</productname> Character Sets</title>
993      <tgroup cols="7">
994       <colspec colname="col1" colwidth="3*"/>
995       <colspec colname="col2" colwidth="2*"/>
996       <colspec colname="col3" colwidth="2*"/>
997       <colspec colname="col4" colwidth="1.25*"/>
998       <colspec colname="col5" colwidth="1*"/>
999       <colspec colname="col6" colwidth="1*"/>
1000       <colspec colname="col7" colwidth="2*"/>
1001       <thead>
1002        <row>
1003         <entry>Name</entry>
1004         <entry>Description</entry>
1005         <entry>Language</entry>
1006         <entry>Server?</entry>
1007         <entry>ICU?</entry>
1008         <!--
1009          The Bytes/Char field is populated by looking at the values returned
1010          by pg_wchar_table.mblen function for each encoding.
1011         -->
1012         <entry>Bytes/&zwsp;Char</entry>
1013         <entry>Aliases</entry>
1014        </row>
1015       </thead>
1016       <tbody>
1017        <row>
1018         <entry><literal>BIG5</literal></entry>
1019         <entry>Big Five</entry>
1020         <entry>Traditional Chinese</entry>
1021         <entry>No</entry>
1022         <entry>No</entry>
1023         <entry>1&ndash;2</entry>
1024         <entry><literal>WIN950</literal>, <literal>Windows950</literal></entry>
1025        </row>
1026        <row>
1027         <entry><literal>EUC_CN</literal></entry>
1028         <entry>Extended UNIX Code-CN</entry>
1029         <entry>Simplified Chinese</entry>
1030         <entry>Yes</entry>
1031         <entry>Yes</entry>
1032         <entry>1&ndash;3</entry>
1033         <entry></entry>
1034        </row>
1035        <row>
1036         <entry><literal>EUC_JP</literal></entry>
1037         <entry>Extended UNIX Code-JP</entry>
1038         <entry>Japanese</entry>
1039         <entry>Yes</entry>
1040         <entry>Yes</entry>
1041         <entry>1&ndash;3</entry>
1042         <entry></entry>
1043        </row>
1044        <row>
1045         <entry><literal>EUC_JIS_2004</literal></entry>
1046         <entry>Extended UNIX Code-JP, JIS X 0213</entry>
1047         <entry>Japanese</entry>
1048         <entry>Yes</entry>
1049         <entry>No</entry>
1050         <entry>1&ndash;3</entry>
1051         <entry></entry>
1052        </row>
1053        <row>
1054         <entry><literal>EUC_KR</literal></entry>
1055         <entry>Extended UNIX Code-KR</entry>
1056         <entry>Korean</entry>
1057         <entry>Yes</entry>
1058         <entry>Yes</entry>
1059         <entry>1&ndash;3</entry>
1060         <entry></entry>
1061        </row>
1062        <row>
1063         <entry><literal>EUC_TW</literal></entry>
1064         <entry>Extended UNIX Code-TW</entry>
1065         <entry>Traditional Chinese, Taiwanese</entry>
1066         <entry>Yes</entry>
1067         <entry>Yes</entry>
1068         <entry>1&ndash;3</entry>
1069         <entry></entry>
1070        </row>
1071        <row>
1072         <entry><literal>GB18030</literal></entry>
1073         <entry>National Standard</entry>
1074         <entry>Chinese</entry>
1075         <entry>No</entry>
1076         <entry>No</entry>
1077         <entry>1&ndash;4</entry>
1078         <entry></entry>
1079        </row>
1080        <row>
1081         <entry><literal>GBK</literal></entry>
1082         <entry>Extended National Standard</entry>
1083         <entry>Simplified Chinese</entry>
1084         <entry>No</entry>
1085         <entry>No</entry>
1086         <entry>1&ndash;2</entry>
1087         <entry><literal>WIN936</literal>, <literal>Windows936</literal></entry>
1088        </row>
1089        <row>
1090         <entry><literal>ISO_8859_5</literal></entry>
1091         <entry>ISO 8859-5, <acronym>ECMA</acronym> 113</entry>
1092         <entry>Latin/Cyrillic</entry>
1093         <entry>Yes</entry>
1094         <entry>Yes</entry>
1095         <entry>1</entry>
1096         <entry></entry>
1097        </row>
1098        <row>
1099         <entry><literal>ISO_8859_6</literal></entry>
1100         <entry>ISO 8859-6, <acronym>ECMA</acronym> 114</entry>
1101         <entry>Latin/Arabic</entry>
1102         <entry>Yes</entry>
1103         <entry>Yes</entry>
1104         <entry>1</entry>
1105         <entry></entry>
1106        </row>
1107        <row>
1108         <entry><literal>ISO_8859_7</literal></entry>
1109         <entry>ISO 8859-7, <acronym>ECMA</acronym> 118</entry>
1110         <entry>Latin/Greek</entry>
1111         <entry>Yes</entry>
1112         <entry>Yes</entry>
1113         <entry>1</entry>
1114         <entry></entry>
1115        </row>
1116        <row>
1117         <entry><literal>ISO_8859_8</literal></entry>
1118         <entry>ISO 8859-8, <acronym>ECMA</acronym> 121</entry>
1119         <entry>Latin/Hebrew</entry>
1120         <entry>Yes</entry>
1121         <entry>Yes</entry>
1122         <entry>1</entry>
1123         <entry></entry>
1124        </row>
1125        <row>
1126         <entry><literal>JOHAB</literal></entry>
1127         <entry><acronym>JOHAB</acronym></entry>
1128         <entry>Korean (Hangul)</entry>
1129         <entry>No</entry>
1130         <entry>No</entry>
1131         <entry>1&ndash;3</entry>
1132         <entry></entry>
1133        </row>
1134        <row>
1135         <entry><literal>KOI8R</literal></entry>
1136         <entry><acronym>KOI</acronym>8-R</entry>
1137         <entry>Cyrillic (Russian)</entry>
1138         <entry>Yes</entry>
1139         <entry>Yes</entry>
1140         <entry>1</entry>
1141         <entry><literal>KOI8</literal></entry>
1142        </row>
1143        <row>
1144         <entry><literal>KOI8U</literal></entry>
1145         <entry><acronym>KOI</acronym>8-U</entry>
1146         <entry>Cyrillic (Ukrainian)</entry>
1147         <entry>Yes</entry>
1148         <entry>Yes</entry>
1149         <entry>1</entry>
1150         <entry></entry>
1151        </row>
1152        <row>
1153         <entry><literal>LATIN1</literal></entry>
1154         <entry>ISO 8859-1, <acronym>ECMA</acronym> 94</entry>
1155         <entry>Western European</entry>
1156         <entry>Yes</entry>
1157         <entry>Yes</entry>
1158         <entry>1</entry>
1159         <entry><literal>ISO88591</literal></entry>
1160        </row>
1161        <row>
1162         <entry><literal>LATIN2</literal></entry>
1163         <entry>ISO 8859-2, <acronym>ECMA</acronym> 94</entry>
1164         <entry>Central European</entry>
1165         <entry>Yes</entry>
1166         <entry>Yes</entry>
1167         <entry>1</entry>
1168         <entry><literal>ISO88592</literal></entry>
1169        </row>
1170        <row>
1171         <entry><literal>LATIN3</literal></entry>
1172         <entry>ISO 8859-3, <acronym>ECMA</acronym> 94</entry>
1173         <entry>South European</entry>
1174         <entry>Yes</entry>
1175         <entry>Yes</entry>
1176         <entry>1</entry>
1177         <entry><literal>ISO88593</literal></entry>
1178        </row>
1179        <row>
1180         <entry><literal>LATIN4</literal></entry>
1181         <entry>ISO 8859-4, <acronym>ECMA</acronym> 94</entry>
1182         <entry>North European</entry>
1183         <entry>Yes</entry>
1184         <entry>Yes</entry>
1185         <entry>1</entry>
1186         <entry><literal>ISO88594</literal></entry>
1187        </row>
1188        <row>
1189         <entry><literal>LATIN5</literal></entry>
1190         <entry>ISO 8859-9, <acronym>ECMA</acronym> 128</entry>
1191         <entry>Turkish</entry>
1192         <entry>Yes</entry>
1193         <entry>Yes</entry>
1194         <entry>1</entry>
1195         <entry><literal>ISO88599</literal></entry>
1196        </row>
1197        <row>
1198         <entry><literal>LATIN6</literal></entry>
1199         <entry>ISO 8859-10, <acronym>ECMA</acronym> 144</entry>
1200         <entry>Nordic</entry>
1201         <entry>Yes</entry>
1202         <entry>Yes</entry>
1203         <entry>1</entry>
1204         <entry><literal>ISO885910</literal></entry>
1205        </row>
1206        <row>
1207         <entry><literal>LATIN7</literal></entry>
1208         <entry>ISO 8859-13</entry>
1209         <entry>Baltic</entry>
1210         <entry>Yes</entry>
1211         <entry>Yes</entry>
1212         <entry>1</entry>
1213         <entry><literal>ISO885913</literal></entry>
1214        </row>
1215        <row>
1216         <entry><literal>LATIN8</literal></entry>
1217         <entry>ISO 8859-14</entry>
1218         <entry>Celtic</entry>
1219         <entry>Yes</entry>
1220         <entry>Yes</entry>
1221         <entry>1</entry>
1222         <entry><literal>ISO885914</literal></entry>
1223        </row>
1224        <row>
1225         <entry><literal>LATIN9</literal></entry>
1226         <entry>ISO 8859-15</entry>
1227         <entry>LATIN1 with Euro and accents</entry>
1228         <entry>Yes</entry>
1229         <entry>Yes</entry>
1230         <entry>1</entry>
1231         <entry><literal>ISO885915</literal></entry>
1232        </row>
1233        <row>
1234         <entry><literal>LATIN10</literal></entry>
1235         <entry>ISO 8859-16, <acronym>ASRO</acronym> SR 14111</entry>
1236         <entry>Romanian</entry>
1237         <entry>Yes</entry>
1238         <entry>No</entry>
1239         <entry>1</entry>
1240         <entry><literal>ISO885916</literal></entry>
1241        </row>
1242        <row>
1243         <entry><literal>MULE_INTERNAL</literal></entry>
1244         <entry>Mule internal code</entry>
1245         <entry>Multilingual Emacs</entry>
1246         <entry>Yes</entry>
1247         <entry>No</entry>
1248         <entry>1&ndash;4</entry>
1249         <entry></entry>
1250        </row>
1251        <row>
1252         <entry><literal>SJIS</literal></entry>
1253         <entry>Shift JIS</entry>
1254         <entry>Japanese</entry>
1255         <entry>No</entry>
1256         <entry>No</entry>
1257         <entry>1&ndash;2</entry>
1258         <entry><literal>Mskanji</literal>, <literal>ShiftJIS</literal>, <literal>WIN932</literal>, <literal>Windows932</literal></entry>
1259        </row>
1260        <row>
1261         <entry><literal>SHIFT_JIS_2004</literal></entry>
1262         <entry>Shift JIS, JIS X 0213</entry>
1263         <entry>Japanese</entry>
1264         <entry>No</entry>
1265         <entry>No</entry>
1266         <entry>1&ndash;2</entry>
1267         <entry></entry>
1268        </row>
1269        <row>
1270         <entry><literal>SQL_ASCII</literal></entry>
1271         <entry>unspecified (see text)</entry>
1272         <entry><emphasis>any</emphasis></entry>
1273         <entry>Yes</entry>
1274         <entry>No</entry>
1275         <entry>1</entry>
1276         <entry></entry>
1277        </row>
1278        <row>
1279         <entry><literal>UHC</literal></entry>
1280         <entry>Unified Hangul Code</entry>
1281         <entry>Korean</entry>
1282         <entry>No</entry>
1283         <entry>No</entry>
1284         <entry>1&ndash;2</entry>
1285         <entry><literal>WIN949</literal>, <literal>Windows949</literal></entry>
1286        </row>
1287        <row>
1288         <entry><literal>UTF8</literal></entry>
1289         <entry>Unicode, 8-bit</entry>
1290         <entry><emphasis>all</emphasis></entry>
1291         <entry>Yes</entry>
1292         <entry>Yes</entry>
1293         <entry>1&ndash;4</entry>
1294         <entry><literal>Unicode</literal></entry>
1295        </row>
1296        <row>
1297         <entry><literal>WIN866</literal></entry>
1298         <entry>Windows CP866</entry>
1299         <entry>Cyrillic</entry>
1300         <entry>Yes</entry>
1301         <entry>Yes</entry>
1302         <entry>1</entry>
1303         <entry><literal>ALT</literal></entry>
1304        </row>
1305        <row>
1306         <entry><literal>WIN874</literal></entry>
1307         <entry>Windows CP874</entry>
1308         <entry>Thai</entry>
1309         <entry>Yes</entry>
1310         <entry>No</entry>
1311         <entry>1</entry>
1312         <entry></entry>
1313        </row>
1314        <row>
1315         <entry><literal>WIN1250</literal></entry>
1316         <entry>Windows CP1250</entry>
1317         <entry>Central European</entry>
1318         <entry>Yes</entry>
1319         <entry>Yes</entry>
1320         <entry>1</entry>
1321         <entry></entry>
1322        </row>
1323        <row>
1324         <entry><literal>WIN1251</literal></entry>
1325         <entry>Windows CP1251</entry>
1326         <entry>Cyrillic</entry>
1327         <entry>Yes</entry>
1328         <entry>Yes</entry>
1329         <entry>1</entry>
1330         <entry><literal>WIN</literal></entry>
1331        </row>
1332        <row>
1333         <entry><literal>WIN1252</literal></entry>
1334         <entry>Windows CP1252</entry>
1335         <entry>Western European</entry>
1336         <entry>Yes</entry>
1337         <entry>Yes</entry>
1338         <entry>1</entry>
1339         <entry></entry>
1340        </row>
1341        <row>
1342         <entry><literal>WIN1253</literal></entry>
1343         <entry>Windows CP1253</entry>
1344         <entry>Greek</entry>
1345         <entry>Yes</entry>
1346         <entry>Yes</entry>
1347         <entry>1</entry>
1348         <entry></entry>
1349        </row>
1350        <row>
1351         <entry><literal>WIN1254</literal></entry>
1352         <entry>Windows CP1254</entry>
1353         <entry>Turkish</entry>
1354         <entry>Yes</entry>
1355         <entry>Yes</entry>
1356         <entry>1</entry>
1357         <entry></entry>
1358        </row>
1359        <row>
1360         <entry><literal>WIN1255</literal></entry>
1361         <entry>Windows CP1255</entry>
1362         <entry>Hebrew</entry>
1363         <entry>Yes</entry>
1364         <entry>Yes</entry>
1365         <entry>1</entry>
1366         <entry></entry>
1367        </row>
1368        <row>
1369         <entry><literal>WIN1256</literal></entry>
1370         <entry>Windows CP1256</entry>
1371         <entry>Arabic</entry>
1372         <entry>Yes</entry>
1373         <entry>Yes</entry>
1374         <entry>1</entry>
1375         <entry></entry>
1376        </row>
1377        <row>
1378         <entry><literal>WIN1257</literal></entry>
1379         <entry>Windows CP1257</entry>
1380         <entry>Baltic</entry>
1381         <entry>Yes</entry>
1382         <entry>Yes</entry>
1383         <entry>1</entry>
1384         <entry></entry>
1385        </row>
1386        <row>
1387         <entry><literal>WIN1258</literal></entry>
1388         <entry>Windows CP1258</entry>
1389         <entry>Vietnamese</entry>
1390         <entry>Yes</entry>
1391         <entry>Yes</entry>
1392         <entry>1</entry>
1393         <entry><literal>ABC</literal>, <literal>TCVN</literal>, <literal>TCVN5712</literal>, <literal>VSCII</literal></entry>
1394        </row>
1395       </tbody>
1396      </tgroup>
1397     </table>
1398
1399     <para>
1400      Not all client <acronym>API</acronym>s support all the listed character sets. For example, the
1401      <productname>PostgreSQL</productname>
1402      JDBC driver does not support <literal>MULE_INTERNAL</literal>, <literal>LATIN6</literal>,
1403      <literal>LATIN8</literal>, and <literal>LATIN10</literal>.
1404     </para>
1405
1406     <para>
1407      The <literal>SQL_ASCII</literal> setting behaves considerably differently
1408      from the other settings.  When the server character set is
1409      <literal>SQL_ASCII</literal>, the server interprets byte values 0&ndash;127
1410      according to the ASCII standard, while byte values 128&ndash;255 are taken
1411      as uninterpreted characters.  No encoding conversion will be done when
1412      the setting is <literal>SQL_ASCII</literal>.  Thus, this setting is not so
1413      much a declaration that a specific encoding is in use, as a declaration
1414      of ignorance about the encoding.  In most cases, if you are
1415      working with any non-ASCII data, it is unwise to use the
1416      <literal>SQL_ASCII</literal> setting because
1417      <productname>PostgreSQL</productname> will be unable to help you by
1418      converting or validating non-ASCII characters.
1419     </para>
1420    </sect2>
1421
1422   <sect2>
1423    <title>Setting the Character Set</title>
1424
1425    <para>
1426     <command>initdb</command> defines the default character set (encoding)
1427     for a <productname>PostgreSQL</productname> cluster. For example,
1428
1429<screen>
1430initdb -E EUC_JP
1431</screen>
1432
1433     sets the default character set to
1434     <literal>EUC_JP</literal> (Extended Unix Code for Japanese).  You
1435     can use <option>--encoding</option> instead of
1436     <option>-E</option> if you prefer longer option strings.
1437     If no <option>-E</option> or <option>--encoding</option> option is
1438     given, <command>initdb</command> attempts to determine the appropriate
1439     encoding to use based on the specified or default locale.
1440    </para>
1441
1442    <para>
1443     You can specify a non-default encoding at database creation time,
1444     provided that the encoding is compatible with the selected locale:
1445
1446<screen>
1447createdb -E EUC_KR -T template0 --lc-collate=ko_KR.euckr --lc-ctype=ko_KR.euckr korean
1448</screen>
1449
1450     This will create a database named <literal>korean</literal> that
1451     uses the character set <literal>EUC_KR</literal>, and locale <literal>ko_KR</literal>.
1452     Another way to accomplish this is to use this SQL command:
1453
1454<programlisting>
1455CREATE DATABASE korean WITH ENCODING 'EUC_KR' LC_COLLATE='ko_KR.euckr' LC_CTYPE='ko_KR.euckr' TEMPLATE=template0;
1456</programlisting>
1457
1458     Notice that the above commands specify copying the <literal>template0</literal>
1459     database.  When copying any other database, the encoding and locale
1460     settings cannot be changed from those of the source database, because
1461     that might result in corrupt data.  For more information see
1462     <xref linkend="manage-ag-templatedbs"/>.
1463    </para>
1464
1465    <para>
1466     The encoding for a database is stored in the system catalog
1467     <literal>pg_database</literal>.  You can see it by using the
1468     <command>psql</command> <option>-l</option> option or the
1469     <command>\l</command> command.
1470
1471<screen>
1472$ <userinput>psql -l</userinput>
1473                                         List of databases
1474   Name    |  Owner   | Encoding  |  Collation  |    Ctype    |          Access Privileges
1475-----------+----------+-----------+-------------+-------------+-------------------------------------
1476 clocaledb | hlinnaka | SQL_ASCII | C           | C           |
1477 englishdb | hlinnaka | UTF8      | en_GB.UTF8  | en_GB.UTF8  |
1478 japanese  | hlinnaka | UTF8      | ja_JP.UTF8  | ja_JP.UTF8  |
1479 korean    | hlinnaka | EUC_KR    | ko_KR.euckr | ko_KR.euckr |
1480 postgres  | hlinnaka | UTF8      | fi_FI.UTF8  | fi_FI.UTF8  |
1481 template0 | hlinnaka | UTF8      | fi_FI.UTF8  | fi_FI.UTF8  | {=c/hlinnaka,hlinnaka=CTc/hlinnaka}
1482 template1 | hlinnaka | UTF8      | fi_FI.UTF8  | fi_FI.UTF8  | {=c/hlinnaka,hlinnaka=CTc/hlinnaka}
1483(7 rows)
1484</screen>
1485    </para>
1486
1487    <important>
1488     <para>
1489      On most modern operating systems, <productname>PostgreSQL</productname>
1490      can determine which character set is implied by the <envar>LC_CTYPE</envar>
1491      setting, and it will enforce that only the matching database encoding is
1492      used.  On older systems it is your responsibility to ensure that you use
1493      the encoding expected by the locale you have selected.  A mistake in
1494      this area is likely to lead to strange behavior of locale-dependent
1495      operations such as sorting.
1496     </para>
1497
1498     <para>
1499      <productname>PostgreSQL</productname> will allow superusers to create
1500      databases with <literal>SQL_ASCII</literal> encoding even when
1501      <envar>LC_CTYPE</envar> is not <literal>C</literal> or <literal>POSIX</literal>.  As noted
1502      above, <literal>SQL_ASCII</literal> does not enforce that the data stored in
1503      the database has any particular encoding, and so this choice poses risks
1504      of locale-dependent misbehavior.  Using this combination of settings is
1505      deprecated and may someday be forbidden altogether.
1506     </para>
1507    </important>
1508   </sect2>
1509
1510   <sect2>
1511    <title>Automatic Character Set Conversion Between Server and Client</title>
1512
1513    <para>
1514     <productname>PostgreSQL</productname> supports automatic character
1515     set conversion between server and client for many combinations of
1516     character sets (<xref linkend="multibyte-conversions-supported"/>
1517     shows which ones).
1518    </para>
1519
1520    <para>
1521     To enable automatic character set conversion, you have to
1522     tell <productname>PostgreSQL</productname> the character set
1523     (encoding) you would like to use in the client. There are several
1524     ways to accomplish this:
1525
1526     <itemizedlist>
1527      <listitem>
1528       <para>
1529        Using the <command>\encoding</command> command in
1530        <application>psql</application>.
1531        <command>\encoding</command> allows you to change client
1532        encoding on the fly. For
1533        example, to change the encoding to <literal>SJIS</literal>, type:
1534
1535<programlisting>
1536\encoding SJIS
1537</programlisting>
1538       </para>
1539      </listitem>
1540
1541      <listitem>
1542       <para>
1543        <application>libpq</application> (<xref linkend="libpq-control"/>) has functions to control the client encoding.
1544       </para>
1545      </listitem>
1546
1547      <listitem>
1548       <para>
1549        Using <command>SET client_encoding TO</command>.
1550
1551        Setting the client encoding can be done with this SQL command:
1552
1553<programlisting>
1554SET CLIENT_ENCODING TO '<replaceable>value</replaceable>';
1555</programlisting>
1556
1557        Also you can use the standard SQL syntax <literal>SET NAMES</literal>
1558        for this purpose:
1559
1560<programlisting>
1561SET NAMES '<replaceable>value</replaceable>';
1562</programlisting>
1563
1564        To query the current client encoding:
1565
1566<programlisting>
1567SHOW client_encoding;
1568</programlisting>
1569
1570        To return to the default encoding:
1571
1572<programlisting>
1573RESET client_encoding;
1574</programlisting>
1575       </para>
1576      </listitem>
1577
1578      <listitem>
1579       <para>
1580        Using <envar>PGCLIENTENCODING</envar>. If the environment variable
1581        <envar>PGCLIENTENCODING</envar> is defined in the client's
1582        environment, that client encoding is automatically selected
1583        when a connection to the server is made.  (This can
1584        subsequently be overridden using any of the other methods
1585        mentioned above.)
1586       </para>
1587      </listitem>
1588
1589      <listitem>
1590      <para>
1591       Using the configuration variable <xref
1592       linkend="guc-client-encoding"/>. If the
1593       <varname>client_encoding</varname> variable is set, that client
1594       encoding is automatically selected when a connection to the
1595       server is made.  (This can subsequently be overridden using any
1596       of the other methods mentioned above.)
1597       </para>
1598      </listitem>
1599
1600     </itemizedlist>
1601    </para>
1602
1603    <para>
1604     If the conversion of a particular character is not possible
1605     &mdash; suppose you chose <literal>EUC_JP</literal> for the
1606     server and <literal>LATIN1</literal> for the client, and some
1607     Japanese characters are returned that do not have a representation in
1608     <literal>LATIN1</literal> &mdash; an error is reported.
1609    </para>
1610
1611    <para>
1612     If the client character set is defined as <literal>SQL_ASCII</literal>,
1613     encoding conversion is disabled, regardless of the server's character
1614     set.  (However, if the server's character set is
1615     not <literal>SQL_ASCII</literal>, the server will still check that
1616     incoming data is valid for that encoding; so the net effect is as
1617     though the client character set were the same as the server's.)
1618     Just as for the server, use of <literal>SQL_ASCII</literal> is unwise
1619     unless you are working with all-ASCII data.
1620    </para>
1621   </sect2>
1622
1623   <sect2 id="multibyte-conversions-supported">
1624    <title>Available Character Set Conversions</title>
1625
1626    <para>
1627     <productname>PostgreSQL</productname> allows conversion between any
1628     two character sets for which a conversion function is listed in the
1629     <link linkend="catalog-pg-conversion"><structname>pg_conversion</structname></link>
1630     system catalog.  <productname>PostgreSQL</productname> comes with
1631     some predefined conversions, as summarized in
1632     <xref linkend="multibyte-translation-table"/> and shown in more
1633     detail in <xref linkend="builtin-conversions-table"/>.  You can
1634     create a new conversion using the SQL command
1635     <xref linkend="sql-createconversion"/>.  (To be used for automatic
1636     client/server conversions, a conversion must be marked
1637     as <quote>default</quote> for its character set pair.)
1638    </para>
1639
1640    <table id="multibyte-translation-table">
1641     <title>Built-in Client/Server Character Set Conversions</title>
1642     <tgroup cols="2">
1643      <colspec colname="col1" colwidth="1*"/>
1644      <colspec colname="col2" colwidth="3*"/>
1645      <thead>
1646       <row>
1647        <entry>Server Character Set</entry>
1648        <entry>Available Client Character Sets</entry>
1649       </row>
1650      </thead>
1651      <tbody>
1652       <row>
1653        <entry><literal>BIG5</literal></entry>
1654        <entry><emphasis>not supported as a server encoding</emphasis>
1655        </entry>
1656       </row>
1657       <row>
1658        <entry><literal>EUC_CN</literal></entry>
1659        <entry><emphasis>EUC_CN</emphasis>,
1660        <literal>MULE_INTERNAL</literal>,
1661        <literal>UTF8</literal>
1662        </entry>
1663       </row>
1664       <row>
1665        <entry><literal>EUC_JP</literal></entry>
1666        <entry><emphasis>EUC_JP</emphasis>,
1667        <literal>MULE_INTERNAL</literal>,
1668        <literal>SJIS</literal>,
1669        <literal>UTF8</literal>
1670        </entry>
1671       </row>
1672       <row>
1673        <entry><literal>EUC_JIS_2004</literal></entry>
1674        <entry><emphasis>EUC_JIS_2004</emphasis>,
1675        <literal>SHIFT_JIS_2004</literal>,
1676        <literal>UTF8</literal>
1677        </entry>
1678       </row>
1679       <row>
1680        <entry><literal>EUC_KR</literal></entry>
1681        <entry><emphasis>EUC_KR</emphasis>,
1682        <literal>MULE_INTERNAL</literal>,
1683        <literal>UTF8</literal>
1684        </entry>
1685       </row>
1686       <row>
1687        <entry><literal>EUC_TW</literal></entry>
1688        <entry><emphasis>EUC_TW</emphasis>,
1689        <literal>BIG5</literal>,
1690        <literal>MULE_INTERNAL</literal>,
1691        <literal>UTF8</literal>
1692        </entry>
1693       </row>
1694       <row>
1695        <entry><literal>GB18030</literal></entry>
1696        <entry><emphasis>not supported as a server encoding</emphasis>
1697        </entry>
1698       </row>
1699       <row>
1700        <entry><literal>GBK</literal></entry>
1701        <entry><emphasis>not supported as a server encoding</emphasis>
1702        </entry>
1703       </row>
1704       <row>
1705        <entry><literal>ISO_8859_5</literal></entry>
1706        <entry><emphasis>ISO_8859_5</emphasis>,
1707        <literal>KOI8R</literal>,
1708        <literal>MULE_INTERNAL</literal>,
1709        <literal>UTF8</literal>,
1710        <literal>WIN866</literal>,
1711        <literal>WIN1251</literal>
1712        </entry>
1713       </row>
1714       <row>
1715        <entry><literal>ISO_8859_6</literal></entry>
1716        <entry><emphasis>ISO_8859_6</emphasis>,
1717        <literal>UTF8</literal>
1718        </entry>
1719       </row>
1720       <row>
1721        <entry><literal>ISO_8859_7</literal></entry>
1722        <entry><emphasis>ISO_8859_7</emphasis>,
1723        <literal>UTF8</literal>
1724        </entry>
1725       </row>
1726       <row>
1727        <entry><literal>ISO_8859_8</literal></entry>
1728        <entry><emphasis>ISO_8859_8</emphasis>,
1729        <literal>UTF8</literal>
1730        </entry>
1731       </row>
1732       <row>
1733        <entry><literal>JOHAB</literal></entry>
1734        <entry><emphasis>not supported as a server encoding</emphasis>
1735        </entry>
1736       </row>
1737       <row>
1738        <entry><literal>KOI8R</literal></entry>
1739        <entry><emphasis>KOI8R</emphasis>,
1740        <literal>ISO_8859_5</literal>,
1741        <literal>MULE_INTERNAL</literal>,
1742        <literal>UTF8</literal>,
1743        <literal>WIN866</literal>,
1744        <literal>WIN1251</literal>
1745        </entry>
1746       </row>
1747       <row>
1748        <entry><literal>KOI8U</literal></entry>
1749        <entry><emphasis>KOI8U</emphasis>,
1750        <literal>UTF8</literal>
1751        </entry>
1752       </row>
1753       <row>
1754        <entry><literal>LATIN1</literal></entry>
1755        <entry><emphasis>LATIN1</emphasis>,
1756        <literal>MULE_INTERNAL</literal>,
1757        <literal>UTF8</literal>
1758        </entry>
1759       </row>
1760       <row>
1761        <entry><literal>LATIN2</literal></entry>
1762        <entry><emphasis>LATIN2</emphasis>,
1763        <literal>MULE_INTERNAL</literal>,
1764        <literal>UTF8</literal>,
1765        <literal>WIN1250</literal>
1766        </entry>
1767       </row>
1768       <row>
1769        <entry><literal>LATIN3</literal></entry>
1770        <entry><emphasis>LATIN3</emphasis>,
1771        <literal>MULE_INTERNAL</literal>,
1772        <literal>UTF8</literal>
1773        </entry>
1774       </row>
1775       <row>
1776        <entry><literal>LATIN4</literal></entry>
1777        <entry><emphasis>LATIN4</emphasis>,
1778        <literal>MULE_INTERNAL</literal>,
1779        <literal>UTF8</literal>
1780        </entry>
1781       </row>
1782       <row>
1783        <entry><literal>LATIN5</literal></entry>
1784        <entry><emphasis>LATIN5</emphasis>,
1785        <literal>UTF8</literal>
1786        </entry>
1787       </row>
1788       <row>
1789        <entry><literal>LATIN6</literal></entry>
1790        <entry><emphasis>LATIN6</emphasis>,
1791        <literal>UTF8</literal>
1792        </entry>
1793       </row>
1794       <row>
1795        <entry><literal>LATIN7</literal></entry>
1796        <entry><emphasis>LATIN7</emphasis>,
1797        <literal>UTF8</literal>
1798        </entry>
1799       </row>
1800       <row>
1801        <entry><literal>LATIN8</literal></entry>
1802        <entry><emphasis>LATIN8</emphasis>,
1803        <literal>UTF8</literal>
1804        </entry>
1805       </row>
1806       <row>
1807        <entry><literal>LATIN9</literal></entry>
1808        <entry><emphasis>LATIN9</emphasis>,
1809        <literal>UTF8</literal>
1810        </entry>
1811       </row>
1812       <row>
1813        <entry><literal>LATIN10</literal></entry>
1814        <entry><emphasis>LATIN10</emphasis>,
1815        <literal>UTF8</literal>
1816        </entry>
1817       </row>
1818       <row>
1819        <entry><literal>MULE_INTERNAL</literal></entry>
1820        <entry><emphasis>MULE_INTERNAL</emphasis>,
1821         <literal>BIG5</literal>,
1822         <literal>EUC_CN</literal>,
1823         <literal>EUC_JP</literal>,
1824         <literal>EUC_KR</literal>,
1825         <literal>EUC_TW</literal>,
1826         <literal>ISO_8859_5</literal>,
1827         <literal>KOI8R</literal>,
1828         <literal>LATIN1</literal> to <literal>LATIN4</literal>,
1829         <literal>SJIS</literal>,
1830         <literal>WIN866</literal>,
1831         <literal>WIN1250</literal>,
1832         <literal>WIN1251</literal>
1833        </entry>
1834       </row>
1835       <row>
1836        <entry><literal>SJIS</literal></entry>
1837        <entry><emphasis>not supported as a server encoding</emphasis>
1838        </entry>
1839       </row>
1840       <row>
1841        <entry><literal>SHIFT_JIS_2004</literal></entry>
1842        <entry><emphasis>not supported as a server encoding</emphasis>
1843        </entry>
1844       </row>
1845       <row>
1846        <entry><literal>SQL_ASCII</literal></entry>
1847        <entry><emphasis>any (no conversion will be performed)</emphasis>
1848        </entry>
1849       </row>
1850       <row>
1851        <entry><literal>UHC</literal></entry>
1852        <entry><emphasis>not supported as a server encoding</emphasis>
1853        </entry>
1854       </row>
1855       <row>
1856        <entry><literal>UTF8</literal></entry>
1857        <entry><emphasis>all supported encodings</emphasis>
1858        </entry>
1859       </row>
1860       <row>
1861        <entry><literal>WIN866</literal></entry>
1862        <entry><emphasis>WIN866</emphasis>,
1863         <literal>ISO_8859_5</literal>,
1864         <literal>KOI8R</literal>,
1865         <literal>MULE_INTERNAL</literal>,
1866         <literal>UTF8</literal>,
1867         <literal>WIN1251</literal>
1868        </entry>
1869       </row>
1870       <row>
1871        <entry><literal>WIN874</literal></entry>
1872        <entry><emphasis>WIN874</emphasis>,
1873        <literal>UTF8</literal>
1874        </entry>
1875       </row>
1876       <row>
1877        <entry><literal>WIN1250</literal></entry>
1878        <entry><emphasis>WIN1250</emphasis>,
1879         <literal>LATIN2</literal>,
1880         <literal>MULE_INTERNAL</literal>,
1881         <literal>UTF8</literal>
1882        </entry>
1883       </row>
1884       <row>
1885        <entry><literal>WIN1251</literal></entry>
1886        <entry><emphasis>WIN1251</emphasis>,
1887         <literal>ISO_8859_5</literal>,
1888         <literal>KOI8R</literal>,
1889         <literal>MULE_INTERNAL</literal>,
1890         <literal>UTF8</literal>,
1891         <literal>WIN866</literal>
1892        </entry>
1893       </row>
1894       <row>
1895        <entry><literal>WIN1252</literal></entry>
1896        <entry><emphasis>WIN1252</emphasis>,
1897         <literal>UTF8</literal>
1898        </entry>
1899       </row>
1900       <row>
1901        <entry><literal>WIN1253</literal></entry>
1902        <entry><emphasis>WIN1253</emphasis>,
1903         <literal>UTF8</literal>
1904        </entry>
1905       </row>
1906       <row>
1907        <entry><literal>WIN1254</literal></entry>
1908        <entry><emphasis>WIN1254</emphasis>,
1909         <literal>UTF8</literal>
1910        </entry>
1911       </row>
1912       <row>
1913        <entry><literal>WIN1255</literal></entry>
1914        <entry><emphasis>WIN1255</emphasis>,
1915         <literal>UTF8</literal>
1916        </entry>
1917       </row>
1918       <row>
1919        <entry><literal>WIN1256</literal></entry>
1920        <entry><emphasis>WIN1256</emphasis>,
1921        <literal>UTF8</literal>
1922        </entry>
1923       </row>
1924       <row>
1925        <entry><literal>WIN1257</literal></entry>
1926        <entry><emphasis>WIN1257</emphasis>,
1927         <literal>UTF8</literal>
1928        </entry>
1929       </row>
1930       <row>
1931        <entry><literal>WIN1258</literal></entry>
1932        <entry><emphasis>WIN1258</emphasis>,
1933        <literal>UTF8</literal>
1934        </entry>
1935       </row>
1936      </tbody>
1937     </tgroup>
1938    </table>
1939
1940    <table id="builtin-conversions-table">
1941     <title>All Built-in Character Set Conversions</title>
1942     <tgroup cols="3">
1943      <colspec colname="col1" colwidth="2*"/>
1944      <colspec colname="col2" colwidth="1*"/>
1945      <colspec colname="col3" colwidth="1*"/>
1946      <thead>
1947       <row>
1948        <entry>Conversion Name
1949         <footnote>
1950          <para>
1951           The conversion names follow a standard naming scheme: The
1952           official name of the source encoding with all
1953           non-alphanumeric characters replaced by underscores, followed
1954           by <literal>_to_</literal>, followed by the similarly processed
1955           destination encoding name.  Therefore, these names sometimes
1956           deviate from the customary encoding names shown in
1957           <xref linkend="charset-table"/>.
1958          </para>
1959         </footnote>
1960        </entry>
1961        <entry>Source Encoding</entry>
1962        <entry>Destination Encoding</entry>
1963       </row>
1964      </thead>
1965
1966      <tbody>
1967       <row>
1968        <entry><literal>big5_to_euc_tw</literal></entry>
1969        <entry><literal>BIG5</literal></entry>
1970        <entry><literal>EUC_TW</literal></entry>
1971       </row>
1972       <row>
1973        <entry><literal>big5_to_mic</literal></entry>
1974        <entry><literal>BIG5</literal></entry>
1975        <entry><literal>MULE_INTERNAL</literal></entry>
1976       </row>
1977       <row>
1978        <entry><literal>big5_to_utf8</literal></entry>
1979        <entry><literal>BIG5</literal></entry>
1980        <entry><literal>UTF8</literal></entry>
1981       </row>
1982       <row>
1983        <entry><literal>euc_cn_to_mic</literal></entry>
1984        <entry><literal>EUC_CN</literal></entry>
1985        <entry><literal>MULE_INTERNAL</literal></entry>
1986       </row>
1987       <row>
1988        <entry><literal>euc_cn_to_utf8</literal></entry>
1989        <entry><literal>EUC_CN</literal></entry>
1990        <entry><literal>UTF8</literal></entry>
1991       </row>
1992       <row>
1993        <entry><literal>euc_jp_to_mic</literal></entry>
1994        <entry><literal>EUC_JP</literal></entry>
1995        <entry><literal>MULE_INTERNAL</literal></entry>
1996       </row>
1997       <row>
1998        <entry><literal>euc_jp_to_sjis</literal></entry>
1999        <entry><literal>EUC_JP</literal></entry>
2000        <entry><literal>SJIS</literal></entry>
2001       </row>
2002       <row>
2003        <entry><literal>euc_jp_to_utf8</literal></entry>
2004        <entry><literal>EUC_JP</literal></entry>
2005        <entry><literal>UTF8</literal></entry>
2006       </row>
2007       <row>
2008        <entry><literal>euc_kr_to_mic</literal></entry>
2009        <entry><literal>EUC_KR</literal></entry>
2010        <entry><literal>MULE_INTERNAL</literal></entry>
2011       </row>
2012       <row>
2013        <entry><literal>euc_kr_to_utf8</literal></entry>
2014        <entry><literal>EUC_KR</literal></entry>
2015        <entry><literal>UTF8</literal></entry>
2016       </row>
2017       <row>
2018        <entry><literal>euc_tw_to_big5</literal></entry>
2019        <entry><literal>EUC_TW</literal></entry>
2020        <entry><literal>BIG5</literal></entry>
2021       </row>
2022       <row>
2023        <entry><literal>euc_tw_to_mic</literal></entry>
2024        <entry><literal>EUC_TW</literal></entry>
2025        <entry><literal>MULE_INTERNAL</literal></entry>
2026       </row>
2027       <row>
2028        <entry><literal>euc_tw_to_utf8</literal></entry>
2029        <entry><literal>EUC_TW</literal></entry>
2030        <entry><literal>UTF8</literal></entry>
2031       </row>
2032       <row>
2033        <entry><literal>gb18030_to_utf8</literal></entry>
2034        <entry><literal>GB18030</literal></entry>
2035        <entry><literal>UTF8</literal></entry>
2036       </row>
2037       <row>
2038        <entry><literal>gbk_to_utf8</literal></entry>
2039        <entry><literal>GBK</literal></entry>
2040        <entry><literal>UTF8</literal></entry>
2041       </row>
2042       <row>
2043        <entry><literal>iso_8859_10_to_utf8</literal></entry>
2044        <entry><literal>LATIN6</literal></entry>
2045        <entry><literal>UTF8</literal></entry>
2046       </row>
2047       <row>
2048        <entry><literal>iso_8859_13_to_utf8</literal></entry>
2049        <entry><literal>LATIN7</literal></entry>
2050        <entry><literal>UTF8</literal></entry>
2051       </row>
2052       <row>
2053        <entry><literal>iso_8859_14_to_utf8</literal></entry>
2054        <entry><literal>LATIN8</literal></entry>
2055        <entry><literal>UTF8</literal></entry>
2056       </row>
2057       <row>
2058        <entry><literal>iso_8859_15_to_utf8</literal></entry>
2059        <entry><literal>LATIN9</literal></entry>
2060        <entry><literal>UTF8</literal></entry>
2061       </row>
2062       <row>
2063        <entry><literal>iso_8859_16_to_utf8</literal></entry>
2064        <entry><literal>LATIN10</literal></entry>
2065        <entry><literal>UTF8</literal></entry>
2066       </row>
2067       <row>
2068        <entry><literal>iso_8859_1_to_mic</literal></entry>
2069        <entry><literal>LATIN1</literal></entry>
2070        <entry><literal>MULE_INTERNAL</literal></entry>
2071       </row>
2072       <row>
2073        <entry><literal>iso_8859_1_to_utf8</literal></entry>
2074        <entry><literal>LATIN1</literal></entry>
2075        <entry><literal>UTF8</literal></entry>
2076       </row>
2077       <row>
2078        <entry><literal>iso_8859_2_to_mic</literal></entry>
2079        <entry><literal>LATIN2</literal></entry>
2080        <entry><literal>MULE_INTERNAL</literal></entry>
2081       </row>
2082       <row>
2083        <entry><literal>iso_8859_2_to_utf8</literal></entry>
2084        <entry><literal>LATIN2</literal></entry>
2085        <entry><literal>UTF8</literal></entry>
2086       </row>
2087       <row>
2088        <entry><literal>iso_8859_2_to_windows_1250</literal></entry>
2089        <entry><literal>LATIN2</literal></entry>
2090        <entry><literal>WIN1250</literal></entry>
2091       </row>
2092       <row>
2093        <entry><literal>iso_8859_3_to_mic</literal></entry>
2094        <entry><literal>LATIN3</literal></entry>
2095        <entry><literal>MULE_INTERNAL</literal></entry>
2096       </row>
2097       <row>
2098        <entry><literal>iso_8859_3_to_utf8</literal></entry>
2099        <entry><literal>LATIN3</literal></entry>
2100        <entry><literal>UTF8</literal></entry>
2101       </row>
2102       <row>
2103        <entry><literal>iso_8859_4_to_mic</literal></entry>
2104        <entry><literal>LATIN4</literal></entry>
2105        <entry><literal>MULE_INTERNAL</literal></entry>
2106       </row>
2107       <row>
2108        <entry><literal>iso_8859_4_to_utf8</literal></entry>
2109        <entry><literal>LATIN4</literal></entry>
2110        <entry><literal>UTF8</literal></entry>
2111       </row>
2112       <row>
2113        <entry><literal>iso_8859_5_to_koi8_r</literal></entry>
2114        <entry><literal>ISO_8859_5</literal></entry>
2115        <entry><literal>KOI8R</literal></entry>
2116       </row>
2117       <row>
2118        <entry><literal>iso_8859_5_to_mic</literal></entry>
2119        <entry><literal>ISO_8859_5</literal></entry>
2120        <entry><literal>MULE_INTERNAL</literal></entry>
2121       </row>
2122       <row>
2123        <entry><literal>iso_8859_5_to_utf8</literal></entry>
2124        <entry><literal>ISO_8859_5</literal></entry>
2125        <entry><literal>UTF8</literal></entry>
2126       </row>
2127       <row>
2128        <entry><literal>iso_8859_5_to_windows_1251</literal></entry>
2129        <entry><literal>ISO_8859_5</literal></entry>
2130        <entry><literal>WIN1251</literal></entry>
2131       </row>
2132       <row>
2133        <entry><literal>iso_8859_5_to_windows_866</literal></entry>
2134        <entry><literal>ISO_8859_5</literal></entry>
2135        <entry><literal>WIN866</literal></entry>
2136       </row>
2137       <row>
2138        <entry><literal>iso_8859_6_to_utf8</literal></entry>
2139        <entry><literal>ISO_8859_6</literal></entry>
2140        <entry><literal>UTF8</literal></entry>
2141       </row>
2142       <row>
2143        <entry><literal>iso_8859_7_to_utf8</literal></entry>
2144        <entry><literal>ISO_8859_7</literal></entry>
2145        <entry><literal>UTF8</literal></entry>
2146       </row>
2147       <row>
2148        <entry><literal>iso_8859_8_to_utf8</literal></entry>
2149        <entry><literal>ISO_8859_8</literal></entry>
2150        <entry><literal>UTF8</literal></entry>
2151       </row>
2152       <row>
2153        <entry><literal>iso_8859_9_to_utf8</literal></entry>
2154        <entry><literal>LATIN5</literal></entry>
2155        <entry><literal>UTF8</literal></entry>
2156       </row>
2157       <row>
2158        <entry><literal>johab_to_utf8</literal></entry>
2159        <entry><literal>JOHAB</literal></entry>
2160        <entry><literal>UTF8</literal></entry>
2161       </row>
2162       <row>
2163        <entry><literal>koi8_r_to_iso_8859_5</literal></entry>
2164        <entry><literal>KOI8R</literal></entry>
2165        <entry><literal>ISO_8859_5</literal></entry>
2166       </row>
2167       <row>
2168        <entry><literal>koi8_r_to_mic</literal></entry>
2169        <entry><literal>KOI8R</literal></entry>
2170        <entry><literal>MULE_INTERNAL</literal></entry>
2171       </row>
2172       <row>
2173        <entry><literal>koi8_r_to_utf8</literal></entry>
2174        <entry><literal>KOI8R</literal></entry>
2175        <entry><literal>UTF8</literal></entry>
2176       </row>
2177       <row>
2178        <entry><literal>koi8_r_to_windows_1251</literal></entry>
2179        <entry><literal>KOI8R</literal></entry>
2180        <entry><literal>WIN1251</literal></entry>
2181       </row>
2182       <row>
2183        <entry><literal>koi8_r_to_windows_866</literal></entry>
2184        <entry><literal>KOI8R</literal></entry>
2185        <entry><literal>WIN866</literal></entry>
2186       </row>
2187       <row>
2188        <entry><literal>koi8_u_to_utf8</literal></entry>
2189        <entry><literal>KOI8U</literal></entry>
2190        <entry><literal>UTF8</literal></entry>
2191       </row>
2192       <row>
2193        <entry><literal>mic_to_big5</literal></entry>
2194        <entry><literal>MULE_INTERNAL</literal></entry>
2195        <entry><literal>BIG5</literal></entry>
2196       </row>
2197       <row>
2198        <entry><literal>mic_to_euc_cn</literal></entry>
2199        <entry><literal>MULE_INTERNAL</literal></entry>
2200        <entry><literal>EUC_CN</literal></entry>
2201       </row>
2202       <row>
2203        <entry><literal>mic_to_euc_jp</literal></entry>
2204        <entry><literal>MULE_INTERNAL</literal></entry>
2205        <entry><literal>EUC_JP</literal></entry>
2206       </row>
2207       <row>
2208        <entry><literal>mic_to_euc_kr</literal></entry>
2209        <entry><literal>MULE_INTERNAL</literal></entry>
2210        <entry><literal>EUC_KR</literal></entry>
2211       </row>
2212       <row>
2213        <entry><literal>mic_to_euc_tw</literal></entry>
2214        <entry><literal>MULE_INTERNAL</literal></entry>
2215        <entry><literal>EUC_TW</literal></entry>
2216       </row>
2217       <row>
2218        <entry><literal>mic_to_iso_8859_1</literal></entry>
2219        <entry><literal>MULE_INTERNAL</literal></entry>
2220        <entry><literal>LATIN1</literal></entry>
2221       </row>
2222       <row>
2223        <entry><literal>mic_to_iso_8859_2</literal></entry>
2224        <entry><literal>MULE_INTERNAL</literal></entry>
2225        <entry><literal>LATIN2</literal></entry>
2226       </row>
2227       <row>
2228        <entry><literal>mic_to_iso_8859_3</literal></entry>
2229        <entry><literal>MULE_INTERNAL</literal></entry>
2230        <entry><literal>LATIN3</literal></entry>
2231       </row>
2232       <row>
2233        <entry><literal>mic_to_iso_8859_4</literal></entry>
2234        <entry><literal>MULE_INTERNAL</literal></entry>
2235        <entry><literal>LATIN4</literal></entry>
2236       </row>
2237       <row>
2238        <entry><literal>mic_to_iso_8859_5</literal></entry>
2239        <entry><literal>MULE_INTERNAL</literal></entry>
2240        <entry><literal>ISO_8859_5</literal></entry>
2241       </row>
2242       <row>
2243        <entry><literal>mic_to_koi8_r</literal></entry>
2244        <entry><literal>MULE_INTERNAL</literal></entry>
2245        <entry><literal>KOI8R</literal></entry>
2246       </row>
2247       <row>
2248        <entry><literal>mic_to_sjis</literal></entry>
2249        <entry><literal>MULE_INTERNAL</literal></entry>
2250        <entry><literal>SJIS</literal></entry>
2251       </row>
2252       <row>
2253        <entry><literal>mic_to_windows_1250</literal></entry>
2254        <entry><literal>MULE_INTERNAL</literal></entry>
2255        <entry><literal>WIN1250</literal></entry>
2256       </row>
2257       <row>
2258        <entry><literal>mic_to_windows_1251</literal></entry>
2259        <entry><literal>MULE_INTERNAL</literal></entry>
2260        <entry><literal>WIN1251</literal></entry>
2261       </row>
2262       <row>
2263        <entry><literal>mic_to_windows_866</literal></entry>
2264        <entry><literal>MULE_INTERNAL</literal></entry>
2265        <entry><literal>WIN866</literal></entry>
2266       </row>
2267       <row>
2268        <entry><literal>sjis_to_euc_jp</literal></entry>
2269        <entry><literal>SJIS</literal></entry>
2270        <entry><literal>EUC_JP</literal></entry>
2271       </row>
2272       <row>
2273        <entry><literal>sjis_to_mic</literal></entry>
2274        <entry><literal>SJIS</literal></entry>
2275        <entry><literal>MULE_INTERNAL</literal></entry>
2276       </row>
2277       <row>
2278        <entry><literal>sjis_to_utf8</literal></entry>
2279        <entry><literal>SJIS</literal></entry>
2280        <entry><literal>UTF8</literal></entry>
2281       </row>
2282       <row>
2283        <entry><literal>windows_1258_to_utf8</literal></entry>
2284        <entry><literal>WIN1258</literal></entry>
2285        <entry><literal>UTF8</literal></entry>
2286       </row>
2287       <row>
2288        <entry><literal>uhc_to_utf8</literal></entry>
2289        <entry><literal>UHC</literal></entry>
2290        <entry><literal>UTF8</literal></entry>
2291       </row>
2292       <row>
2293        <entry><literal>utf8_to_big5</literal></entry>
2294        <entry><literal>UTF8</literal></entry>
2295        <entry><literal>BIG5</literal></entry>
2296       </row>
2297       <row>
2298        <entry><literal>utf8_to_euc_cn</literal></entry>
2299        <entry><literal>UTF8</literal></entry>
2300        <entry><literal>EUC_CN</literal></entry>
2301       </row>
2302       <row>
2303        <entry><literal>utf8_to_euc_jp</literal></entry>
2304        <entry><literal>UTF8</literal></entry>
2305        <entry><literal>EUC_JP</literal></entry>
2306       </row>
2307       <row>
2308        <entry><literal>utf8_to_euc_kr</literal></entry>
2309        <entry><literal>UTF8</literal></entry>
2310        <entry><literal>EUC_KR</literal></entry>
2311       </row>
2312       <row>
2313        <entry><literal>utf8_to_euc_tw</literal></entry>
2314        <entry><literal>UTF8</literal></entry>
2315        <entry><literal>EUC_TW</literal></entry>
2316       </row>
2317       <row>
2318        <entry><literal>utf8_to_gb18030</literal></entry>
2319        <entry><literal>UTF8</literal></entry>
2320        <entry><literal>GB18030</literal></entry>
2321       </row>
2322       <row>
2323        <entry><literal>utf8_to_gbk</literal></entry>
2324        <entry><literal>UTF8</literal></entry>
2325        <entry><literal>GBK</literal></entry>
2326       </row>
2327       <row>
2328        <entry><literal>utf8_to_iso_8859_1</literal></entry>
2329        <entry><literal>UTF8</literal></entry>
2330        <entry><literal>LATIN1</literal></entry>
2331       </row>
2332       <row>
2333        <entry><literal>utf8_to_iso_8859_10</literal></entry>
2334        <entry><literal>UTF8</literal></entry>
2335        <entry><literal>LATIN6</literal></entry>
2336       </row>
2337       <row>
2338        <entry><literal>utf8_to_iso_8859_13</literal></entry>
2339        <entry><literal>UTF8</literal></entry>
2340        <entry><literal>LATIN7</literal></entry>
2341       </row>
2342       <row>
2343        <entry><literal>utf8_to_iso_8859_14</literal></entry>
2344        <entry><literal>UTF8</literal></entry>
2345        <entry><literal>LATIN8</literal></entry>
2346       </row>
2347       <row>
2348        <entry><literal>utf8_to_iso_8859_15</literal></entry>
2349        <entry><literal>UTF8</literal></entry>
2350        <entry><literal>LATIN9</literal></entry>
2351       </row>
2352       <row>
2353        <entry><literal>utf8_to_iso_8859_16</literal></entry>
2354        <entry><literal>UTF8</literal></entry>
2355        <entry><literal>LATIN10</literal></entry>
2356       </row>
2357       <row>
2358        <entry><literal>utf8_to_iso_8859_2</literal></entry>
2359        <entry><literal>UTF8</literal></entry>
2360        <entry><literal>LATIN2</literal></entry>
2361       </row>
2362       <row>
2363        <entry><literal>utf8_to_iso_8859_3</literal></entry>
2364        <entry><literal>UTF8</literal></entry>
2365        <entry><literal>LATIN3</literal></entry>
2366       </row>
2367       <row>
2368        <entry><literal>utf8_to_iso_8859_4</literal></entry>
2369        <entry><literal>UTF8</literal></entry>
2370        <entry><literal>LATIN4</literal></entry>
2371       </row>
2372       <row>
2373        <entry><literal>utf8_to_iso_8859_5</literal></entry>
2374        <entry><literal>UTF8</literal></entry>
2375        <entry><literal>ISO_8859_5</literal></entry>
2376       </row>
2377       <row>
2378        <entry><literal>utf8_to_iso_8859_6</literal></entry>
2379        <entry><literal>UTF8</literal></entry>
2380        <entry><literal>ISO_8859_6</literal></entry>
2381       </row>
2382       <row>
2383        <entry><literal>utf8_to_iso_8859_7</literal></entry>
2384        <entry><literal>UTF8</literal></entry>
2385        <entry><literal>ISO_8859_7</literal></entry>
2386       </row>
2387       <row>
2388        <entry><literal>utf8_to_iso_8859_8</literal></entry>
2389        <entry><literal>UTF8</literal></entry>
2390        <entry><literal>ISO_8859_8</literal></entry>
2391       </row>
2392       <row>
2393        <entry><literal>utf8_to_iso_8859_9</literal></entry>
2394        <entry><literal>UTF8</literal></entry>
2395        <entry><literal>LATIN5</literal></entry>
2396       </row>
2397       <row>
2398        <entry><literal>utf8_to_johab</literal></entry>
2399        <entry><literal>UTF8</literal></entry>
2400        <entry><literal>JOHAB</literal></entry>
2401       </row>
2402       <row>
2403        <entry><literal>utf8_to_koi8_r</literal></entry>
2404        <entry><literal>UTF8</literal></entry>
2405        <entry><literal>KOI8R</literal></entry>
2406       </row>
2407       <row>
2408        <entry><literal>utf8_to_koi8_u</literal></entry>
2409        <entry><literal>UTF8</literal></entry>
2410        <entry><literal>KOI8U</literal></entry>
2411       </row>
2412       <row>
2413        <entry><literal>utf8_to_sjis</literal></entry>
2414        <entry><literal>UTF8</literal></entry>
2415        <entry><literal>SJIS</literal></entry>
2416       </row>
2417       <row>
2418        <entry><literal>utf8_to_windows_1258</literal></entry>
2419        <entry><literal>UTF8</literal></entry>
2420        <entry><literal>WIN1258</literal></entry>
2421       </row>
2422       <row>
2423        <entry><literal>utf8_to_uhc</literal></entry>
2424        <entry><literal>UTF8</literal></entry>
2425        <entry><literal>UHC</literal></entry>
2426       </row>
2427       <row>
2428        <entry><literal>utf8_to_windows_1250</literal></entry>
2429        <entry><literal>UTF8</literal></entry>
2430        <entry><literal>WIN1250</literal></entry>
2431       </row>
2432       <row>
2433        <entry><literal>utf8_to_windows_1251</literal></entry>
2434        <entry><literal>UTF8</literal></entry>
2435        <entry><literal>WIN1251</literal></entry>
2436       </row>
2437       <row>
2438        <entry><literal>utf8_to_windows_1252</literal></entry>
2439        <entry><literal>UTF8</literal></entry>
2440        <entry><literal>WIN1252</literal></entry>
2441       </row>
2442       <row>
2443        <entry><literal>utf8_to_windows_1253</literal></entry>
2444        <entry><literal>UTF8</literal></entry>
2445        <entry><literal>WIN1253</literal></entry>
2446       </row>
2447       <row>
2448        <entry><literal>utf8_to_windows_1254</literal></entry>
2449        <entry><literal>UTF8</literal></entry>
2450        <entry><literal>WIN1254</literal></entry>
2451       </row>
2452       <row>
2453        <entry><literal>utf8_to_windows_1255</literal></entry>
2454        <entry><literal>UTF8</literal></entry>
2455        <entry><literal>WIN1255</literal></entry>
2456       </row>
2457       <row>
2458        <entry><literal>utf8_to_windows_1256</literal></entry>
2459        <entry><literal>UTF8</literal></entry>
2460        <entry><literal>WIN1256</literal></entry>
2461       </row>
2462       <row>
2463        <entry><literal>utf8_to_windows_1257</literal></entry>
2464        <entry><literal>UTF8</literal></entry>
2465        <entry><literal>WIN1257</literal></entry>
2466       </row>
2467       <row>
2468        <entry><literal>utf8_to_windows_866</literal></entry>
2469        <entry><literal>UTF8</literal></entry>
2470        <entry><literal>WIN866</literal></entry>
2471       </row>
2472       <row>
2473        <entry><literal>utf8_to_windows_874</literal></entry>
2474        <entry><literal>UTF8</literal></entry>
2475        <entry><literal>WIN874</literal></entry>
2476       </row>
2477       <row>
2478        <entry><literal>windows_1250_to_iso_8859_2</literal></entry>
2479        <entry><literal>WIN1250</literal></entry>
2480        <entry><literal>LATIN2</literal></entry>
2481       </row>
2482       <row>
2483        <entry><literal>windows_1250_to_mic</literal></entry>
2484        <entry><literal>WIN1250</literal></entry>
2485        <entry><literal>MULE_INTERNAL</literal></entry>
2486       </row>
2487       <row>
2488        <entry><literal>windows_1250_to_utf8</literal></entry>
2489        <entry><literal>WIN1250</literal></entry>
2490        <entry><literal>UTF8</literal></entry>
2491       </row>
2492       <row>
2493        <entry><literal>windows_1251_to_iso_8859_5</literal></entry>
2494        <entry><literal>WIN1251</literal></entry>
2495        <entry><literal>ISO_8859_5</literal></entry>
2496       </row>
2497       <row>
2498        <entry><literal>windows_1251_to_koi8_r</literal></entry>
2499        <entry><literal>WIN1251</literal></entry>
2500        <entry><literal>KOI8R</literal></entry>
2501       </row>
2502       <row>
2503        <entry><literal>windows_1251_to_mic</literal></entry>
2504        <entry><literal>WIN1251</literal></entry>
2505        <entry><literal>MULE_INTERNAL</literal></entry>
2506       </row>
2507       <row>
2508        <entry><literal>windows_1251_to_utf8</literal></entry>
2509        <entry><literal>WIN1251</literal></entry>
2510        <entry><literal>UTF8</literal></entry>
2511       </row>
2512       <row>
2513        <entry><literal>windows_1251_to_windows_866</literal></entry>
2514        <entry><literal>WIN1251</literal></entry>
2515        <entry><literal>WIN866</literal></entry>
2516       </row>
2517       <row>
2518        <entry><literal>windows_1252_to_utf8</literal></entry>
2519        <entry><literal>WIN1252</literal></entry>
2520        <entry><literal>UTF8</literal></entry>
2521       </row>
2522       <row>
2523        <entry><literal>windows_1256_to_utf8</literal></entry>
2524        <entry><literal>WIN1256</literal></entry>
2525        <entry><literal>UTF8</literal></entry>
2526       </row>
2527       <row>
2528        <entry><literal>windows_866_to_iso_8859_5</literal></entry>
2529        <entry><literal>WIN866</literal></entry>
2530        <entry><literal>ISO_8859_5</literal></entry>
2531       </row>
2532       <row>
2533        <entry><literal>windows_866_to_koi8_r</literal></entry>
2534        <entry><literal>WIN866</literal></entry>
2535        <entry><literal>KOI8R</literal></entry>
2536       </row>
2537       <row>
2538        <entry><literal>windows_866_to_mic</literal></entry>
2539        <entry><literal>WIN866</literal></entry>
2540        <entry><literal>MULE_INTERNAL</literal></entry>
2541       </row>
2542       <row>
2543        <entry><literal>windows_866_to_utf8</literal></entry>
2544        <entry><literal>WIN866</literal></entry>
2545        <entry><literal>UTF8</literal></entry>
2546       </row>
2547       <row>
2548        <entry><literal>windows_866_to_windows_1251</literal></entry>
2549        <entry><literal>WIN866</literal></entry>
2550        <entry><literal>WIN</literal></entry>
2551       </row>
2552       <row>
2553        <entry><literal>windows_874_to_utf8</literal></entry>
2554        <entry><literal>WIN874</literal></entry>
2555        <entry><literal>UTF8</literal></entry>
2556       </row>
2557       <row>
2558        <entry><literal>euc_jis_2004_to_utf8</literal></entry>
2559        <entry><literal>EUC_JIS_2004</literal></entry>
2560        <entry><literal>UTF8</literal></entry>
2561       </row>
2562       <row>
2563        <entry><literal>utf8_to_euc_jis_2004</literal></entry>
2564        <entry><literal>UTF8</literal></entry>
2565        <entry><literal>EUC_JIS_2004</literal></entry>
2566       </row>
2567       <row>
2568        <entry><literal>shift_jis_2004_to_utf8</literal></entry>
2569        <entry><literal>SHIFT_JIS_2004</literal></entry>
2570        <entry><literal>UTF8</literal></entry>
2571       </row>
2572       <row>
2573        <entry><literal>utf8_to_shift_jis_2004</literal></entry>
2574        <entry><literal>UTF8</literal></entry>
2575        <entry><literal>SHIFT_JIS_2004</literal></entry>
2576       </row>
2577       <row>
2578        <entry><literal>euc_jis_2004_to_shift_jis_2004</literal></entry>
2579        <entry><literal>EUC_JIS_2004</literal></entry>
2580        <entry><literal>SHIFT_JIS_2004</literal></entry>
2581       </row>
2582       <row>
2583        <entry><literal>shift_jis_2004_to_euc_jis_2004</literal></entry>
2584        <entry><literal>SHIFT_JIS_2004</literal></entry>
2585        <entry><literal>EUC_JIS_2004</literal></entry>
2586       </row>
2587      </tbody>
2588     </tgroup>
2589    </table>
2590   </sect2>
2591
2592   <sect2>
2593    <title>Further Reading</title>
2594
2595    <para>
2596     These are good sources to start learning about various kinds of encoding
2597     systems.
2598
2599     <variablelist>
2600      <varlistentry>
2601       <term><citetitle>CJKV Information Processing: Chinese, Japanese, Korean &amp; Vietnamese Computing</citetitle></term>
2602
2603       <listitem>
2604        <para>
2605         Contains detailed explanations of <literal>EUC_JP</literal>,
2606         <literal>EUC_CN</literal>, <literal>EUC_KR</literal>,
2607         <literal>EUC_TW</literal>.
2608        </para>
2609       </listitem>
2610      </varlistentry>
2611
2612      <varlistentry>
2613       <term><ulink url="https://www.unicode.org/"></ulink></term>
2614
2615       <listitem>
2616        <para>
2617         The web site of the Unicode Consortium.
2618        </para>
2619       </listitem>
2620      </varlistentry>
2621
2622      <varlistentry>
2623       <term>RFC 3629</term>
2624
2625       <listitem>
2626        <para>
2627         <acronym>UTF</acronym>-8 (8-bit UCS/Unicode Transformation
2628         Format) is defined here.
2629        </para>
2630       </listitem>
2631      </varlistentry>
2632     </variablelist>
2633    </para>
2634   </sect2>
2635
2636  </sect1>
2637
2638</chapter>
2639