2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Charset conversion functions.
8 if (! defined('PHPMYADMIN')) {
12 define('PMA_CHARSET_NONE', 0);
13 define('PMA_CHARSET_ICONV', 1);
14 define('PMA_CHARSET_RECODE', 2);
15 define('PMA_CHARSET_ICONV_AIX', 3);
17 // Finally detect which function we will use:
18 if ($cfg['RecodingEngine'] == 'iconv') {
19 if (@function_exists
('iconv')) {
20 if ((@stristr
(PHP_OS
, 'AIX')) && (@strcasecmp
(ICONV_IMPL
, 'unknown') == 0) && (@strcasecmp
(ICONV_VERSION
, 'unknown') == 0)) {
21 $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX
;
23 $PMA_recoding_engine = PMA_CHARSET_ICONV
;
26 $PMA_recoding_engine = PMA_CHARSET_NONE
;
27 PMA_warnMissingExtension('iconv');
29 } elseif ($cfg['RecodingEngine'] == 'recode') {
30 if (@function_exists
('recode_string')) {
31 $PMA_recoding_engine = PMA_CHARSET_RECODE
;
33 $PMA_recoding_engine = PMA_CHARSET_NONE
;
34 PMA_warnMissingExtension('recode');
36 } elseif ($cfg['RecodingEngine'] == 'auto') {
37 if (@function_exists
('iconv')) {
38 if ((@stristr
(PHP_OS
, 'AIX')) && (@strcasecmp
(ICONV_IMPL
, 'unknown') == 0) && (@strcasecmp
(ICONV_VERSION
, 'unknown') == 0)) {
39 $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX
;
41 $PMA_recoding_engine = PMA_CHARSET_ICONV
;
43 } elseif (@function_exists
('recode_string')) {
44 $PMA_recoding_engine = PMA_CHARSET_RECODE
;
46 $PMA_recoding_engine = PMA_CHARSET_NONE
;
49 $PMA_recoding_engine = PMA_CHARSET_NONE
;
52 /* Load AIX iconv wrapper if needed */
53 if ($PMA_recoding_engine == PMA_CHARSET_ICONV_AIX
) {
54 include_once './libraries/iconv_wrapper.lib.php';
58 * Converts encoding of text according to parameters with detected
59 * conversion function.
61 * @param string source charset
62 * @param string target charset
63 * @param string what to convert
65 * @return string converted text
70 function PMA_convert_string($src_charset, $dest_charset, $what)
72 if ($src_charset == $dest_charset) {
75 switch ($GLOBALS['PMA_recoding_engine']) {
76 case PMA_CHARSET_RECODE
:
77 return recode_string($src_charset . '..' . $dest_charset, $what);
78 case PMA_CHARSET_ICONV
:
79 return iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what);
80 case PMA_CHARSET_ICONV_AIX
:
81 return PMA_aix_iconv_wrapper($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what);
85 } // end of the "PMA_convert_string()" function