1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-->
<refentry id="fn_charset_recode">
<refmeta>
<refentrytitle>charset_recode</refentrytitle>
<refmiscinfo>localization</refmiscinfo>
</refmeta>
<refnamediv>
<refname>charset_recode</refname>
<refpurpose>Translate a string to another character set</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_charset_recode">
<funcprototype id="fproto_charset_recode">
<funcdef>any <function>charset_recode</function> </funcdef>
<paramdef>in <parameter>src_string</parameter> varchar/nvarchar</paramdef>
<paramdef>in <parameter>src_charset</parameter> varchar</paramdef>
<paramdef>in <parameter>dst_charset</parameter> varchar</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_charset_recode">
<title>Description</title>
<para>This function translates a string from a given source charset to a destination charset. It provides a generic way of recoding string entities.</para>
<para>The <parameter>src_charset</parameter> may be a narrow or a wide <type>string</type>. If it's a <type>narrow string</type> (<type>VARCHAR</type>) then the <parameter>src_charset</parameter> is taken into account and defines the current encoding of the <parameter>src_string</parameter>. In any other case <parameter>src_charset</parameter> is ignored.</para>
<para><parameter>src_charset</parameter> and <parameter>dst_charset</parameter> are names of system-defined 8 bit charset tables. Use <function>charsets_list</function> to obtain a list of currently defined character sets and aliases. If either of these is null, then the charset in effect is used. There are two special character set names - "UTF-8" and "_WIDE_" - that are recognized by this function. These represent UTF-8 encoding of characters and <type>wide string</type> (<type>NVARCHAR</type>).</para>
</refsect1>
<refsect1 id="params_charset_recode"><title>Parameters</title>
<refsect2><title><parameter>src_string</parameter></title>
<para>The input data to be converted. <type>String</type> or <type>wide string.</type></para>
</refsect2>
<refsect2><title><parameter>src_charset</parameter></title>
<para>Input data character set, <type>string</type>.</para>
</refsect2>
<refsect2><title>dst_charset</title>
<para>The charset to convert to, <type>string</type>.</para>
</refsect2>
</refsect1>
<refsect1 id="examples_charset_recode"><title>Examples</title>
<example id="ex_charset_define_01">
<title>Recoding a narrow ISO-8859-1 string as UTF-8</title>
<screen>
select cast (charset_recode ('\xA9', 'ISO-8859-1', 'UTF-8') as varbinary)
-- converts "Copyright sign" to UTF-8 (output 0xC2A9)
select cast (charset_recode ('\xC0', 'WINDOWS-1251', 'ISO-8859-5') as varbinary)
-- converts "Cyrillic A" from WINDOWS-1251 charset to ISO-8859-5 (output 0xB0).
select cast (charset_recode (N'\x410', '_WIDE_', 'WINDOWS-1251') as varbinary)
-- converts "Cyrillic A" from Unicode to WINDOWS-1251 charset (result '\xC0').
select charset_recode (N'\x410', '_WIDE_', 'ISO-8859-1')
-- converts "Cyrillic A" from Unicode to ISO-8859-1 charset (Not available : result '?').
</screen>
<!-- select charset_recode ('\xC0', 'WINDOWS-1251', '_WIDE_') - - converts "Cyrillic A" from WINDOWS-1251 charset to NVARCHAR (result N'\x410'). did not work - returned ? -->
</example>
</refsect1>
<refsect1 id="seealso_charset_recode"><title>See Also</title>
<para><link linkend="fn_elh_get_handler">elh_get_handler</link></para>
<para><link linkend="fn_elh_load_handler">elh_load_handler</link></para>
<para><link linkend="fn_lh_get_handler">lh_get_handler</link></para>
<para><link linkend="fn_lh_load_handler">lh_load_handler</link></para>
</refsect1>
</refentry>
|