Translation update done using Pootle.
[phpmyadmin/madhuracj.git] / libraries / charset_conversion.lib.php
blob8d19ad436fe0f0b331c074718070c7bc614ec6e6
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Charset conversion functions.
6 * @package phpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
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;
22 } else {
23 $PMA_recoding_engine = PMA_CHARSET_ICONV;
25 } else {
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;
32 } else {
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;
40 } else {
41 $PMA_recoding_engine = PMA_CHARSET_ICONV;
43 } elseif (@function_exists('recode_string')) {
44 $PMA_recoding_engine = PMA_CHARSET_RECODE;
45 } else {
46 $PMA_recoding_engine = PMA_CHARSET_NONE;
48 } else {
49 $PMA_recoding_engine = PMA_CHARSET_NONE;
52 /* Load AIX iconv wrapper if needed */
53 if ($PMA_recoding_engine == PMA_CHARSET_ICONV_AIX) {
54 require_once './libraries/iconv_wrapper.lib.php';
57 /**
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
67 * @access public
70 function PMA_convert_string($src_charset, $dest_charset, $what)
72 if ($src_charset == $dest_charset) {
73 return $what;
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);
82 default:
83 return $what;
85 } // end of the "PMA_convert_string()" function