123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <?php
- /**
- * decode/koi8-r.php
- *
- * This file contains koi8-r decoding function that is needed to read
- * koi8-r encoded mails in non-koi8-r locale.
- *
- * Original data taken from:
- * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/KOI8-R.TXT
- *
- * Name: KOI8-R (RFC1489) to Unicode
- * Unicode version: 3.0
- * Table version: 1.0
- * Table format: Format A
- * Date: 18 August 1999
- * Authors: Helmut Richter <richter@lrz.de>
- *
- * Copyright (c) 1991-1999 Unicode, Inc. All Rights reserved.
- *
- * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- * No claims are made as to fitness for any particular purpose. No
- * warranties of any kind are expressed or implied. The recipient
- * agrees to determine applicability of information provided. If this
- * file has been provided on optical media by Unicode, Inc., the sole
- * remedy for any claim will be exchange of defective media within 90
- * days of receipt.
- *
- * Unicode, Inc. hereby grants the right to freely use the information
- * supplied in this file in the creation of products supporting the
- * Unicode Standard, and to make copies of this file in any form for
- * internal or external distribution as long as this notice remains
- * attached.
- *
- * @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 koi8r strings
- * @param string $string Encoded string
- * @return string Decoded string
- */
- function charset_decode_koi8_r ($string) {
- // don't do decoding when there are no 8bit symbols
- if (! sq_is8bit($string,'koi8-r'))
- return $string;
- $koi8r = 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($koi8r), array_values($koi8r), $string);
- return $string;
- }
|