~hexmode/+junk/main

« back to all changes in this revision

Viewing changes to install-files/apps/phpmyadmin2.10.1/libraries/iconv_wrapper.lib.php

  • Committer: Mark A. Hershberger
  • Date: 2008-01-05 19:38:56 UTC
  • Revision ID: hershberger@spawn-xp-20080105193856-6rnzgwa4nehue3qj
initial commit

Show diffs side-by-side

added added

removed removed

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