1. Check existence of mb_string, mysql and xml extensions before installation.
[openemr.git] / phpmyadmin / libraries / iconv_wrapper.lib.php
blobf1d74dbbacfc6624dfb4c3634027b22a2221fe7d
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 = /*overload*/mb_strpos(
80 /*overload*/mb_strtolower($out_charset),
81 '//translit'
83 $using_translit = (!($translit_search === false));
85 // Extract "plain" output character set name
86 // (without any transliteration argument)
87 $out_charset_plain = ($using_translit
88 ? /*overload*/mb_substr($out_charset, 0, $translit_search)
89 : $out_charset);
91 // Transform name of input character set (if found)
92 $in_charset_exisits = array_key_exists(
93 /*overload*/mb_strtolower($in_charset),
94 $gnu_iconv_to_aix_iconv_codepage_map
96 if ($in_charset_exisits) {
97 $in_charset = $gnu_iconv_to_aix_iconv_codepage_map[
98 /*overload*/mb_strtolower($in_charset)
102 // Transform name of "plain" output character set (if found)
103 $out_charset_plain_exists = array_key_exists(
104 /*overload*/mb_strtolower($out_charset_plain),
105 $gnu_iconv_to_aix_iconv_codepage_map
107 if ($out_charset_plain_exists) {
108 $out_charset_plain = $gnu_iconv_to_aix_iconv_codepage_map[
109 /*overload*/mb_strtolower($out_charset_plain)
113 // Add transliteration argument again (exactly as specified by user) if used
114 // Build the output character set name that we will use
115 /* Not needed because always overwritten
116 $out_charset = ($using_translit
117 ? $out_charset_plain . $pmaString->substr($out_charset, $translit_search)
118 : $out_charset_plain);
121 // NOTE: Transliteration not supported; we will use the "plain"
122 // output character set name
123 $out_charset = $out_charset_plain;
125 return array($in_charset, $out_charset);