added japanese language
[openemr.git] / phpmyadmin / libraries / iconv_wrapper.lib.php
blobbc822e6fee34afc96fc7875a859fbdf9da412d05
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Iconv wrapper for AIX
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
13 * GNU iconv code set to IBM AIX libiconv code set table
14 * Keys of this table should be in lowercase,
15 * and searches should be performed using lowercase!
17 $gnu_iconv_to_aix_iconv_codepage_map = array (
18 // "iso-8859-[1-9]" --> "ISO8859-[1-9]" according to
19 // http://publibn.boulder.ibm.com/doc_link/en_US/
20 // a_doc_lib/libs/basetrf2/setlocale.htm
21 'iso-8859-1' => 'ISO8859-1',
22 'iso-8859-2' => 'ISO8859-2',
23 'iso-8859-3' => 'ISO8859-3',
24 'iso-8859-4' => 'ISO8859-4',
25 'iso-8859-5' => 'ISO8859-5',
26 'iso-8859-6' => 'ISO8859-6',
27 'iso-8859-7' => 'ISO8859-7',
28 'iso-8859-8' => 'ISO8859-8',
29 'iso-8859-9' => 'ISO8859-9',
31 // "big5" --> "IBM-eucTW" according to
32 // http://kadesh.cepba.upc.es/mancpp/classref/ref/ITranscoder_DSC.htm
33 'big5' => 'IBM-eucTW',
35 // Other mappings corresponding to the phpMyAdmin dropdown box when using the
36 // charset conversion feature
37 'euc-jp' => 'IBM-eucJP',
38 'koi8-r' => 'IBM-eucKR',
39 'ks_c_5601-1987' => 'KSC5601.1987-0',
40 'tis-620' => 'TIS-620',
41 'utf-8' => 'UTF-8'
44 /**
45 * Wrapper around IBM AIX iconv(), whose character set naming differs
46 * from the GNU version of iconv().
48 * @param string $in_charset input character set
49 * @param string $out_charset output character set
50 * @param string $str the string to convert
52 * @return mixed converted string or false on failure
54 * @access public
57 function PMA_convertAIXIconv($in_charset, $out_charset, $str)
59 list($in_charset, $out_charset) = PMA_convertAIXMapCharsets(
60 $in_charset, $out_charset
62 // Call iconv() with the possibly modified parameters
63 return iconv($in_charset, $out_charset, $str);
64 } // end of the "PMA_convertAIXIconv()" function
66 /**
67 * Maps input and output character set names to corresponding AIX ones
69 * @param string $in_charset input character set
70 * @param string $out_charset output character set
72 * @return array array of mapped input and output character set names
74 function PMA_convertAIXMapCharsets($in_charset, $out_charset)
76 global $gnu_iconv_to_aix_iconv_codepage_map;
78 // Check for transliteration argument at the end of output character set name
79 $translit_search = strpos(strtolower($out_charset), '//translit');
80 $using_translit = (!($translit_search === false));
82 // Extract "plain" output character set name
83 // (without any transliteration argument)
84 $out_charset_plain = ($using_translit
85 ? substr($out_charset, 0, $translit_search)
86 : $out_charset);
88 // Transform name of input character set (if found)
89 $in_charset_exisits = array_key_exists(
90 strtolower($in_charset),
91 $gnu_iconv_to_aix_iconv_codepage_map
93 if ($in_charset_exisits) {
94 $in_charset = $gnu_iconv_to_aix_iconv_codepage_map[strtolower($in_charset)];
97 // Transform name of "plain" output character set (if found)
98 $out_charset_plain_exists = array_key_exists(
99 strtolower($out_charset_plain),
100 $gnu_iconv_to_aix_iconv_codepage_map
102 if ($out_charset_plain_exists) {
103 $out_charset_plain = $gnu_iconv_to_aix_iconv_codepage_map[
104 strtolower($out_charset_plain)];
107 // Add transliteration argument again (exactly as specified by user) if used
108 // Build the output character set name that we will use
109 $out_charset = ($using_translit
110 ? $out_charset_plain . substr($out_charset, $translit_search)
111 : $out_charset_plain);
113 // NOTE: Transliteration not supported; we will use the "plain"
114 // output character set name
115 $out_charset = $out_charset_plain;
117 return array($in_charset, $out_charset);