home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / iconv_wrapper.lib.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  3.2 KB  |  87 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: iconv_wrapper.lib.php 11326 2008-06-17 21:32:48Z lem9 $
  6.  */
  7. if (! defined('PHPMYADMIN')) {
  8.     exit;
  9. }
  10.  
  11. /**
  12.  *
  13.  */
  14. # GNU iconv code set to IBM AIX libiconv code set table
  15. # Keys of this table should be in lowercase, and searches should be performed using lowercase!
  16. $gnu_iconv_to_aix_iconv_codepage_map = array (
  17.     // "iso-8859-[1-9]" --> "ISO8859-[1-9]" according to http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/libs/basetrf2/setlocale.htm
  18.     'iso-8859-1' => 'ISO8859-1',
  19.     'iso-8859-2' => 'ISO8859-2',
  20.     'iso-8859-3' => 'ISO8859-3',
  21.     'iso-8859-4' => 'ISO8859-4',
  22.     'iso-8859-5' => 'ISO8859-5',
  23.     'iso-8859-6' => 'ISO8859-6',
  24.     'iso-8859-7' => 'ISO8859-7',
  25.     'iso-8859-8' => 'ISO8859-8',
  26.     'iso-8859-9' => 'ISO8859-9',
  27.  
  28.     // "big5" --> "IBM-eucTW" according to http://kadesh.cepba.upc.es/mancpp/classref/ref/ITranscoder_DSC.htm
  29.     'big5' => 'IBM-eucTW',
  30.  
  31.     // Other mappings corresponding to the phpMyAdmin dropdown box when using the AllowAnywhereRecoding feature
  32.     'euc-jp' => 'IBM-eucJP',
  33.     'koi8-r' => 'IBM-eucKR',
  34.     'ks_c_5601-1987' => 'KSC5601.1987-0',
  35.     'tis-620' => 'TIS-620',
  36.     'utf-8' => 'UTF-8'
  37. );
  38.  
  39. /**
  40.  * Wrapper around IBM AIX iconv(), whose character set naming differs
  41.  * from the GNU version of iconv().
  42.  *
  43.  * @param   string   input character set
  44.  * @param   string   output character set
  45.  * @param   string   the string to convert
  46.  *
  47.  * @return  mixed    converted string or FALSE on failure
  48.  *
  49.  * @access  public
  50.  *
  51.  * @author  bwiberg  Bj├╢rn Wiberg <Bjorn.Wiberg@its.uu.se>
  52.  */
  53. function PMA_aix_iconv_wrapper($in_charset, $out_charset, $str) {
  54.  
  55.     global $gnu_iconv_to_aix_iconv_codepage_map;
  56.  
  57.     // Check for transliteration argument at the end of output character set name
  58.     $translit_search = strpos(strtolower($out_charset), '//translit');
  59.     $using_translit = (!($translit_search === FALSE));
  60.  
  61.     // Extract "plain" output character set name (without any transliteration argument)
  62.     $out_charset_plain = ($using_translit ? substr($out_charset, 0, $translit_search) : $out_charset);
  63.  
  64.     // Transform name of input character set (if found)
  65.     if (array_key_exists(strtolower($in_charset), $gnu_iconv_to_aix_iconv_codepage_map)) {
  66.         $in_charset = $gnu_iconv_to_aix_iconv_codepage_map[strtolower($in_charset)];
  67.     }
  68.  
  69.     // Transform name of "plain" output character set (if found)
  70.     if (array_key_exists(strtolower($out_charset_plain), $gnu_iconv_to_aix_iconv_codepage_map)) {
  71.         $out_charset_plain = $gnu_iconv_to_aix_iconv_codepage_map[strtolower($out_charset_plain)];
  72.     }
  73.  
  74.     // Add transliteration argument again (exactly as specified by user) if used
  75.     // Build the output character set name that we will use
  76.     $out_charset = ($using_translit ? $out_charset_plain . substr($out_charset, $translit_search) : $out_charset_plain);
  77.  
  78.     // NOTE: Transliteration not supported; we will use the "plain" output character set name
  79.     $out_charset = $out_charset_plain;
  80.  
  81.     // Call iconv() with the possibly modified parameters
  82.     $result = iconv($in_charset, $out_charset, $str);
  83.     return $result;
  84. } //  end of the "PMA_aix_iconv_wrapper()" function
  85.  
  86. ?>
  87.