170 lines
4.7 KiB
PHP
170 lines
4.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* decode/cp855.php
|
|
*
|
|
* This file contains cp855 decoding function that is needed to read
|
|
* cp855 encoded mails in non-cp855 locale.
|
|
*
|
|
* Original data taken from:
|
|
* ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP855.TXT
|
|
* Name: cp855_DOSCyrillic to Unicode table
|
|
* Unicode version: 2.0
|
|
* Table version: 2.00
|
|
* Table format: Format A
|
|
* Date: 04/24/96
|
|
* Authors: Lori Brownell <loribr@microsoft.com>
|
|
* K.D. Chang <a-kchang@microsoft.com>
|
|
*
|
|
* @copyright 2003-2025 The SquirrelMail Project Team
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
* @version $Id$
|
|
* @package squirrelmail
|
|
* @subpackage decode
|
|
*/
|
|
|
|
/**
|
|
* Decode a cp855-encoded string
|
|
* @param string $string Encoded string
|
|
* @return string $string Decoded string
|
|
*/
|
|
function charset_decode_cp855 ($string) {
|
|
// don't do decoding when there are no 8bit symbols
|
|
if (! sq_is8bit($string,'ibm855'))
|
|
return $string;
|
|
|
|
$cp855 = array(
|
|
"\x80" => 'ђ',
|
|
"\x81" => 'Ђ',
|
|
"\x82" => 'ѓ',
|
|
"\x83" => 'Ѓ',
|
|
"\x84" => 'ё',
|
|
"\x85" => 'Ё',
|
|
"\x86" => 'є',
|
|
"\x87" => 'Є',
|
|
"\x88" => 'ѕ',
|
|
"\x89" => 'Ѕ',
|
|
"\x8a" => 'і',
|
|
"\x8b" => 'І',
|
|
"\x8c" => 'ї',
|
|
"\x8d" => 'Ї',
|
|
"\x8e" => 'ј',
|
|
"\x8f" => 'Ј',
|
|
"\x90" => 'љ',
|
|
"\x91" => 'Љ',
|
|
"\x92" => 'њ',
|
|
"\x93" => 'Њ',
|
|
"\x94" => 'ћ',
|
|
"\x95" => 'Ћ',
|
|
"\x96" => 'ќ',
|
|
"\x97" => 'Ќ',
|
|
"\x98" => 'ў',
|
|
"\x99" => 'Ў',
|
|
"\x9a" => 'џ',
|
|
"\x9b" => 'Џ',
|
|
"\x9c" => 'ю',
|
|
"\x9d" => 'Ю',
|
|
"\x9e" => 'ъ',
|
|
"\x9f" => 'Ъ',
|
|
"\xa0" => 'а',
|
|
"\xa1" => 'А',
|
|
"\xa2" => 'б',
|
|
"\xa3" => 'Б',
|
|
"\xa4" => 'ц',
|
|
"\xa5" => 'Ц',
|
|
"\xa6" => 'д',
|
|
"\xa7" => 'Д',
|
|
"\xa8" => 'е',
|
|
"\xa9" => 'Е',
|
|
"\xaa" => 'ф',
|
|
"\xab" => 'Ф',
|
|
"\xac" => 'г',
|
|
"\xad" => 'Г',
|
|
"\xae" => '«',
|
|
"\xaf" => '»',
|
|
"\xb0" => '░',
|
|
"\xb1" => '▒',
|
|
"\xb2" => '▓',
|
|
"\xb3" => '│',
|
|
"\xb4" => '┤',
|
|
"\xb5" => 'х',
|
|
"\xb6" => 'Х',
|
|
"\xb7" => 'и',
|
|
"\xb8" => 'И',
|
|
"\xb9" => '╣',
|
|
"\xba" => '║',
|
|
"\xbb" => '╗',
|
|
"\xbc" => '╝',
|
|
"\xbd" => 'й',
|
|
"\xbe" => 'Й',
|
|
"\xbf" => '┐',
|
|
"\xc0" => '└',
|
|
"\xc1" => '┴',
|
|
"\xc2" => '┬',
|
|
"\xc3" => '├',
|
|
"\xc4" => '─',
|
|
"\xc5" => '┼',
|
|
"\xc6" => 'к',
|
|
"\xc7" => 'К',
|
|
"\xc8" => '╚',
|
|
"\xc9" => '╔',
|
|
"\xca" => '╩',
|
|
"\xcb" => '╦',
|
|
"\xcc" => '╠',
|
|
"\xcd" => '═',
|
|
"\xce" => '╬',
|
|
"\xcf" => '¤',
|
|
"\xd0" => 'л',
|
|
"\xd1" => 'Л',
|
|
"\xd2" => 'м',
|
|
"\xd3" => 'М',
|
|
"\xd4" => 'н',
|
|
"\xd5" => 'Н',
|
|
"\xd6" => 'о',
|
|
"\xd7" => 'О',
|
|
"\xd8" => 'п',
|
|
"\xd9" => '┘',
|
|
"\xda" => '┌',
|
|
"\xdb" => '█',
|
|
"\xdc" => '▄',
|
|
"\xdd" => 'П',
|
|
"\xde" => 'я',
|
|
"\xdf" => '▀',
|
|
"\xe0" => 'Я',
|
|
"\xe1" => 'р',
|
|
"\xe2" => 'Р',
|
|
"\xe3" => 'с',
|
|
"\xe4" => 'С',
|
|
"\xe5" => 'т',
|
|
"\xe6" => 'Т',
|
|
"\xe7" => 'у',
|
|
"\xe8" => 'У',
|
|
"\xe9" => 'ж',
|
|
"\xea" => 'Ж',
|
|
"\xeb" => 'в',
|
|
"\xec" => 'В',
|
|
"\xed" => 'ь',
|
|
"\xee" => 'Ь',
|
|
"\xef" => '№',
|
|
"\xf0" => '­',
|
|
"\xf1" => 'ы',
|
|
"\xf2" => 'Ы',
|
|
"\xf3" => 'з',
|
|
"\xf4" => 'З',
|
|
"\xf5" => 'ш',
|
|
"\xf6" => 'Ш',
|
|
"\xf7" => 'э',
|
|
"\xf8" => 'Э',
|
|
"\xf9" => 'щ',
|
|
"\xfa" => 'Щ',
|
|
"\xfb" => 'ч',
|
|
"\xfc" => 'Ч',
|
|
"\xfd" => '§',
|
|
"\xfe" => '■',
|
|
"\xff" => ' '
|
|
);
|
|
|
|
$string = str_replace(array_keys($cp855), array_values($cp855), $string);
|
|
|
|
return $string;
|
|
}
|