diff options
author | David M <davidmj@users.sourceforge.net> | 2006-12-28 18:59:47 +0000 |
---|---|---|
committer | David M <davidmj@users.sourceforge.net> | 2006-12-28 18:59:47 +0000 |
commit | 7ed8dda36d984962933c613347fb66182faae4a1 (patch) | |
tree | 99ae6efd58156eacd05edaa860f3a0424fcbae40 /phpBB/includes/utf | |
parent | 0af60d92cc2ee837fa2ad36fd97bd92b968607b6 (diff) | |
download | forums-7ed8dda36d984962933c613347fb66182faae4a1.tar forums-7ed8dda36d984962933c613347fb66182faae4a1.tar.gz forums-7ed8dda36d984962933c613347fb66182faae4a1.tar.bz2 forums-7ed8dda36d984962933c613347fb66182faae4a1.tar.xz forums-7ed8dda36d984962933c613347fb66182faae4a1.zip |
hah! finally :D
git-svn-id: file:///svn/phpbb/trunk@6821 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/utf')
-rw-r--r-- | phpBB/includes/utf/utf_tools.php | 105 |
1 files changed, 101 insertions, 4 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index ed803df7e6..b4edff53f5 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -754,14 +754,111 @@ function utf8_recode($string, $encoding) trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); } - global $phpbb_root_path; + global $phpbb_root_path, $phpEx; - if (!file_exists($phpbb_root_path . 'includes/utf/data/')) + // CP/WIN character encoding + if (preg_match('/(?:cp|win)[_\- ]?(\\d+)/i', $encoding, $array)) { - return $string; + switch ($array[1]) + { + case '932': + break; + case '1250': + case '1254': + case '1255': + case '1256': + case '1257': + case '874': + if (!function_exists('cp' . $array[1])) + { + if (!file_exists($phpbb_root_path . 'includes/utf/data/basic.' . $phpEx)) + { + trigger_error('Reencoder file is missing', E_USER_ERROR); + } + include($phpbb_root_path . 'includes/utf/data/basic.' . $phpEx); + } + return call_user_func('cp' . $array[1], $string); + break; + + default: + trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); + break; + } + } + + // iso-8859-* character encoding + if (preg_match('/iso[_ -]?8859[_ -]?(\\d+)/', $encoding, $array)) + { + switch ($array[1]) + { + case '1': + case '2': + case '4': + case '7': + case '9': + case '15': + if (!function_exists('iso_8895_' . $array[1])) + { + if (!file_exists($phpbb_root_path . 'includes/utf/data/basic.' . $phpEx)) + { + trigger_error('Basic reencoder file is missing', E_USER_ERROR); + } + include($phpbb_root_path . 'includes/utf/data/basic.' . $phpEx); + } + return call_user_func('iso_8895_' . $array[1], $string); + break; + + default: + trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); + break; + } + } + + // SJIS + if (preg_match('/sjis(?:[_ -]?win)?|(?:cp|ibm)[_ -]?932|shift[_ -]?jis/i', $encoding) + { + if (!function_exists('sjis')) + { + if (!file_exists($phpbb_root_path . 'includes/utf/data/cjk.' . $phpEx)) + { + trigger_error('CJK reencoder file is missing', E_USER_ERROR); + } + include($phpbb_root_path . 'includes/utf/data/cjk.' . $phpEx); + } + return sjis($string); + } + + // EUC_KR + if (preg_match('/euc[_ -]?kr/i', $encoding) + { + if (!function_exists('euc_kr')) + { + if (!file_exists($phpbb_root_path . 'includes/utf/data/cjk.' . $phpEx)) + { + trigger_error('CJK reencoder file is missing', E_USER_ERROR); + } + include($phpbb_root_path . 'includes/utf/data/cjk.' . $phpEx); + } + return euc_kr($string); + } + + // BIG-5 + if (preg_match('/big[_ -]?5/i', $encoding) + { + if (!function_exists('big5')) + { + if (!file_exists($phpbb_root_path . 'includes/utf/data/cjk.' . $phpEx)) + { + trigger_error('CJK reencoder file is missing', E_USER_ERROR); + } + include($phpbb_root_path . 'includes/utf/data/cjk.' . $phpEx); + } + return big5($string); } - die('Finish me!! ' . basename(__FILE__) . ' at line ' . __LINE__); + // Trigger an error?! Fow now just give bad data :-( + //trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); + return $string; } /** |