123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <?php
- /**
- * decode/cp866.php
- *
- * This file contains cp866 decoding function that is needed to read
- * cp866 encoded mails in non-cp866 locale.
- *
- * Original data taken from:
- * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/
- Name: cp866_DOSCyrillicRussian 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>
- The entries are in cp866_DOSCyrillicRussian order
- *
- * @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 cp866-encoded string
- * @param string $string Encoded string
- * @return string $string Decoded string
- */
- function charset_decode_cp866 ($string) {
- // don't do decoding when there are no 8bit symbols
- if (! sq_is8bit($string,'ibm866'))
- return $string;
- $cp866 = 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($cp866), array_values($cp866), $string);
- return $string;
- }
|