diff options
author | David M <davidmj@users.sourceforge.net> | 2007-01-07 04:24:08 +0000 |
---|---|---|
committer | David M <davidmj@users.sourceforge.net> | 2007-01-07 04:24:08 +0000 |
commit | a643f85f6b33f8e0a8a30b5eb6696a40b78e2abd (patch) | |
tree | 24b843100c6ab913e3b01e11d2157d55b388bfde | |
parent | f3b514368210c7d0328d5aeaf70341bd082a06f3 (diff) | |
download | forums-a643f85f6b33f8e0a8a30b5eb6696a40b78e2abd.tar forums-a643f85f6b33f8e0a8a30b5eb6696a40b78e2abd.tar.gz forums-a643f85f6b33f8e0a8a30b5eb6696a40b78e2abd.tar.bz2 forums-a643f85f6b33f8e0a8a30b5eb6696a40b78e2abd.tar.xz forums-a643f85f6b33f8e0a8a30b5eb6696a40b78e2abd.zip |
- prefer ISO over CP as ISO is more common
- added TIS-620 and cp-1251
git-svn-id: file:///svn/phpbb/trunk@6849 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/includes/utf/data/recode_basic.php | 262 | ||||
-rw-r--r-- | phpBB/includes/utf/utf_tools.php | 59 |
2 files changed, 299 insertions, 22 deletions
diff --git a/phpBB/includes/utf/data/recode_basic.php b/phpBB/includes/utf/data/recode_basic.php index 1f8599547f..1a9d7af745 100644 --- a/phpBB/includes/utf/data/recode_basic.php +++ b/phpBB/includes/utf/data/recode_basic.php @@ -434,6 +434,133 @@ function iso_8895_15($string) return strtr(utf8_encode($string), $transform); } +// nearly the same as iso-8859-11 +function tis_620($string) +{ + static $transform = array( + "\x80" => "\xC2\x80", + "\x81" => "\xC2\x81", + "\x82" => "\xC2\x82", + "\x83" => "\xC2\x83", + "\x84" => "\xC2\x84", + "\x85" => "\xC2\x85", + "\x86" => "\xC2\x86", + "\x87" => "\xC2\x87", + "\x88" => "\xC2\x88", + "\x89" => "\xC2\x89", + "\x8A" => "\xC2\x8A", + "\x8B" => "\xC2\x8B", + "\x8C" => "\xC2\x8C", + "\x8D" => "\xC2\x8D", + "\x8E" => "\xC2\x8E", + "\x8F" => "\xC2\x8F", + "\x90" => "\xC2\x90", + "\x91" => "\xC2\x91", + "\x92" => "\xC2\x92", + "\x93" => "\xC2\x93", + "\x94" => "\xC2\x94", + "\x95" => "\xC2\x95", + "\x96" => "\xC2\x96", + "\x97" => "\xC2\x97", + "\x98" => "\xC2\x98", + "\x99" => "\xC2\x99", + "\x9A" => "\xC2\x9A", + "\x9B" => "\xC2\x9B", + "\x9C" => "\xC2\x9C", + "\x9D" => "\xC2\x9D", + "\x9E" => "\xC2\x9E", + "\x9F" => "\xC2\x9F", + "\xA1" => "\xE0\xB8\x81", + "\xA2" => "\xE0\xB8\x82", + "\xA3" => "\xE0\xB8\x83", + "\xA4" => "\xE0\xB8\x84", + "\xA5" => "\xE0\xB8\x85", + "\xA6" => "\xE0\xB8\x86", + "\xA7" => "\xE0\xB8\x87", + "\xA8" => "\xE0\xB8\x88", + "\xA9" => "\xE0\xB8\x89", + "\xAA" => "\xE0\xB8\x8A", + "\xAB" => "\xE0\xB8\x8B", + "\xAC" => "\xE0\xB8\x8C", + "\xAD" => "\xE0\xB8\x8D", + "\xAE" => "\xE0\xB8\x8E", + "\xAF" => "\xE0\xB8\x8F", + "\xB0" => "\xE0\xB8\x90", + "\xB1" => "\xE0\xB8\x91", + "\xB2" => "\xE0\xB8\x92", + "\xB3" => "\xE0\xB8\x93", + "\xB4" => "\xE0\xB8\x94", + "\xB5" => "\xE0\xB8\x95", + "\xB6" => "\xE0\xB8\x96", + "\xB7" => "\xE0\xB8\x97", + "\xB8" => "\xE0\xB8\x98", + "\xB9" => "\xE0\xB8\x99", + "\xBA" => "\xE0\xB8\x9A", + "\xBB" => "\xE0\xB8\x9B", + "\xBC" => "\xE0\xB8\x9C", + "\xBD" => "\xE0\xB8\x9D", + "\xBE" => "\xE0\xB8\x9E", + "\xBF" => "\xE0\xB8\x9F", + "\xC0" => "\xE0\xB8\xA0", + "\xC1" => "\xE0\xB8\xA1", + "\xC2" => "\xE0\xB8\xA2", + "\xC3" => "\xE0\xB8\xA3", + "\xC4" => "\xE0\xB8\xA4", + "\xC5" => "\xE0\xB8\xA5", + "\xC6" => "\xE0\xB8\xA6", + "\xC7" => "\xE0\xB8\xA7", + "\xC8" => "\xE0\xB8\xA8", + "\xC9" => "\xE0\xB8\xA9", + "\xCA" => "\xE0\xB8\xAA", + "\xCB" => "\xE0\xB8\xAB", + "\xCC" => "\xE0\xB8\xAC", + "\xCD" => "\xE0\xB8\xAD", + "\xCE" => "\xE0\xB8\xAE", + "\xCF" => "\xE0\xB8\xAF", + "\xD0" => "\xE0\xB8\xB0", + "\xD1" => "\xE0\xB8\xB1", + "\xD2" => "\xE0\xB8\xB2", + "\xD3" => "\xE0\xB8\xB3", + "\xD4" => "\xE0\xB8\xB4", + "\xD5" => "\xE0\xB8\xB5", + "\xD6" => "\xE0\xB8\xB6", + "\xD7" => "\xE0\xB8\xB7", + "\xD8" => "\xE0\xB8\xB8", + "\xD9" => "\xE0\xB8\xB9", + "\xDA" => "\xE0\xB8\xBA", + "\xDF" => "\xE0\xB8\xBF", + "\xE0" => "\xE0\xB9\x80", + "\xE1" => "\xE0\xB9\x81", + "\xE2" => "\xE0\xB9\x82", + "\xE3" => "\xE0\xB9\x83", + "\xE4" => "\xE0\xB9\x84", + "\xE5" => "\xE0\xB9\x85", + "\xE6" => "\xE0\xB9\x86", + "\xE7" => "\xE0\xB9\x87", + "\xE8" => "\xE0\xB9\x88", + "\xE9" => "\xE0\xB9\x89", + "\xEA" => "\xE0\xB9\x8A", + "\xEB" => "\xE0\xB9\x8B", + "\xEC" => "\xE0\xB9\x8C", + "\xED" => "\xE0\xB9\x8D", + "\xEE" => "\xE0\xB9\x8E", + "\xEF" => "\xE0\xB9\x8F", + "\xF0" => "\xE0\xB9\x90", + "\xF1" => "\xE0\xB9\x91", + "\xF2" => "\xE0\xB9\x92", + "\xF3" => "\xE0\xB9\x93", + "\xF4" => "\xE0\xB9\x94", + "\xF5" => "\xE0\xB9\x95", + "\xF6" => "\xE0\xB9\x96", + "\xF7" => "\xE0\xB9\x97", + "\xF8" => "\xE0\xB9\x98", + "\xF9" => "\xE0\xB9\x99", + "\xFA" => "\xE0\xB9\x9A", + "\xFB" => "\xE0\xB9\x9B", + ); + return strtr($string, $transform); +} + function cp874($string) { static $transform = array( @@ -668,6 +795,140 @@ function cp1250($string) return strtr($string, $transform); } +function cp1251($string) +{ + static $transform = array( + "\x80" => "\xD0\x82", + "\x81" => "\xD0\x83", + "\x82" => "\xE2\x80\x9A", + "\x83" => "\xD1\x93", + "\x84" => "\xE2\x80\x9E", + "\x85" => "\xE2\x80\xA6", + "\x86" => "\xE2\x80\xA0", + "\x87" => "\xE2\x80\xA1", + "\x88" => "\xE2\x82\xAC", + "\x89" => "\xE2\x80\xB0", + "\x8A" => "\xD0\x89", + "\x8B" => "\xE2\x80\xB9", + "\x8C" => "\xD0\x8A", + "\x8D" => "\xD0\x8C", + "\x8E" => "\xD0\x8B", + "\x8F" => "\xD0\x8F", + "\x90" => "\xD1\x92", + "\x91" => "\xE2\x80\x98", + "\x92" => "\xE2\x80\x99", + "\x93" => "\xE2\x80\x9C", + "\x94" => "\xE2\x80\x9D", + "\x95" => "\xE2\x80\xA2", + "\x96" => "\xE2\x80\x93", + "\x97" => "\xE2\x80\x94", + "\x99" => "\xE2\x84\xA2", + "\x9A" => "\xD1\x99", + "\x9B" => "\xE2\x80\xBA", + "\x9C" => "\xD1\x9A", + "\x9D" => "\xD1\x9C", + "\x9E" => "\xD1\x9B", + "\x9F" => "\xD1\x9F", + "\xA0" => "\xC2\xA0", + "\xA1" => "\xD0\x8E", + "\xA2" => "\xD1\x9E", + "\xA3" => "\xD0\x88", + "\xA4" => "\xC2\xA4", + "\xA5" => "\xD2\x90", + "\xA6" => "\xC2\xA6", + "\xA7" => "\xC2\xA7", + "\xA8" => "\xD0\x81", + "\xA9" => "\xC2\xA9", + "\xAA" => "\xD0\x84", + "\xAB" => "\xC2\xAB", + "\xAC" => "\xC2\xAC", + "\xAD" => "\xC2\xAD", + "\xAE" => "\xC2\xAE", + "\xAF" => "\xD0\x87", + "\xB0" => "\xC2\xB0", + "\xB1" => "\xC2\xB1", + "\xB2" => "\xD0\x86", + "\xB3" => "\xD1\x96", + "\xB4" => "\xD2\x91", + "\xB5" => "\xC2\xB5", + "\xB6" => "\xC2\xB6", + "\xB7" => "\xC2\xB7", + "\xB8" => "\xD1\x91", + "\xB9" => "\xE2\x84\x96", + "\xBA" => "\xD1\x94", + "\xBB" => "\xC2\xBB", + "\xBC" => "\xD1\x98", + "\xBD" => "\xD0\x85", + "\xBE" => "\xD1\x95", + "\xBF" => "\xD1\x97", + "\xC0" => "\xD0\x90", + "\xC1" => "\xD0\x91", + "\xC2" => "\xD0\x92", + "\xC3" => "\xD0\x93", + "\xC4" => "\xD0\x94", + "\xC5" => "\xD0\x95", + "\xC6" => "\xD0\x96", + "\xC7" => "\xD0\x97", + "\xC8" => "\xD0\x98", + "\xC9" => "\xD0\x99", + "\xCA" => "\xD0\x9A", + "\xCB" => "\xD0\x9B", + "\xCC" => "\xD0\x9C", + "\xCD" => "\xD0\x9D", + "\xCE" => "\xD0\x9E", + "\xCF" => "\xD0\x9F", + "\xD0" => "\xD0\xA0", + "\xD1" => "\xD0\xA1", + "\xD2" => "\xD0\xA2", + "\xD3" => "\xD0\xA3", + "\xD4" => "\xD0\xA4", + "\xD5" => "\xD0\xA5", + "\xD6" => "\xD0\xA6", + "\xD7" => "\xD0\xA7", + "\xD8" => "\xD0\xA8", + "\xD9" => "\xD0\xA9", + "\xDA" => "\xD0\xAA", + "\xDB" => "\xD0\xAB", + "\xDC" => "\xD0\xAC", + "\xDD" => "\xD0\xAD", + "\xDE" => "\xD0\xAE", + "\xDF" => "\xD0\xAF", + "\xE0" => "\xD0\xB0", + "\xE1" => "\xD0\xB1", + "\xE2" => "\xD0\xB2", + "\xE3" => "\xD0\xB3", + "\xE4" => "\xD0\xB4", + "\xE5" => "\xD0\xB5", + "\xE6" => "\xD0\xB6", + "\xE7" => "\xD0\xB7", + "\xE8" => "\xD0\xB8", + "\xE9" => "\xD0\xB9", + "\xEA" => "\xD0\xBA", + "\xEB" => "\xD0\xBB", + "\xEC" => "\xD0\xBC", + "\xED" => "\xD0\xBD", + "\xEE" => "\xD0\xBE", + "\xEF" => "\xD0\xBF", + "\xF0" => "\xD1\x80", + "\xF1" => "\xD1\x81", + "\xF2" => "\xD1\x82", + "\xF3" => "\xD1\x83", + "\xF4" => "\xD1\x84", + "\xF5" => "\xD1\x85", + "\xF6" => "\xD1\x86", + "\xF7" => "\xD1\x87", + "\xF8" => "\xD1\x88", + "\xF9" => "\xD1\x89", + "\xFA" => "\xD1\x8A", + "\xFB" => "\xD1\x8B", + "\xFC" => "\xD1\x8C", + "\xFD" => "\xD1\x8D", + "\xFE" => "\xD1\x8E", + "\xFF" => "\xD1\x8F", + ); + return strtr($string, $transform); +} + function cp1254($string) { static $tranform = array( @@ -817,6 +1078,7 @@ function cp1255($string) ); return strtr($string, $transform); } + function cp1256($string) { static $transform = array( diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 39868f71e9..ec233cf986 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -756,20 +756,18 @@ function utf8_recode($string, $encoding) global $phpbb_root_path, $phpEx; - // CP/WIN character encoding - if (preg_match('/(?:cp|windows)[_\- ]?(\\d+)/', $encoding, $array)) + // iso-8859-* character encoding + if (preg_match('/iso[_ -]?8859[_ -]?(\\d+)/', $encoding, $array)) { switch ($array[1]) { - case '932': - break; - case '1250': - case '1254': - case '1255': - case '1256': - case '1257': - case '874': - if (!function_exists('cp' . $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/recode_basic.' . $phpEx)) { @@ -777,7 +775,7 @@ function utf8_recode($string, $encoding) } include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx); } - return call_user_func('cp' . $array[1], $string); + return call_user_func('iso_8895_' . $array[1], $string); break; default: @@ -786,18 +784,21 @@ function utf8_recode($string, $encoding) } } - // iso-8859-* character encoding - if (preg_match('/iso[_ -]?8859[_ -]?(\\d+)/', $encoding, $array)) + // CP/WIN character encoding + if (preg_match('/(?:cp|windows)[_\- ]?(\\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])) + case '932': + break; + case '1250': + case '1251': + 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/recode_basic.' . $phpEx)) { @@ -805,7 +806,7 @@ function utf8_recode($string, $encoding) } include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx); } - return call_user_func('iso_8895_' . $array[1], $string); + return call_user_func('cp' . $array[1], $string); break; default: @@ -814,6 +815,20 @@ function utf8_recode($string, $encoding) } } + // TIS-620 + if (preg_match('/tis[_ -]?620/', $encoding)) + { + if (!function_exists('tis_620')) + { + if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx)) + { + trigger_error('Basic reencoder file is missing', E_USER_ERROR); + } + include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx); + } + return tis_620($string); + } + // SJIS if (preg_match('/sjis(?:[_ -]?win)?|(?:cp|ibm)[_ -]?932|shift[_ -]?jis/', $encoding)) { |