198 lines
5.2 KiB
PHP
198 lines
5.2 KiB
PHP
<?php
|
|
/**
|
|
* decode/koi8-u.php
|
|
*
|
|
* Copyright (c) 2003-2004 The SquirrelMail Project Team
|
|
* Licensed under the GNU GPL. For full terms see the file COPYING.
|
|
*
|
|
* This file contains koi8-u decoding function that is needed to read
|
|
* koi8-u encoded mails in non-koi8-u locale.
|
|
*
|
|
* Original data taken from rfc2319
|
|
*
|
|
* Original copyright:
|
|
*
|
|
* Copyright (C) The Internet Society (1998). All Rights Reserved.
|
|
*
|
|
* This document and translations of it may be copied and furnished to
|
|
* others, and derivative works that comment on or otherwise explain it
|
|
* or assist in its implementation may be prepared, copied, published
|
|
* and distributed, in whole or in part, without restriction of any
|
|
* kind, provided that the above copyright notice and this paragraph are
|
|
* included on all such copies and derivative works. However, this
|
|
* document itself may not be modified in any way, such as by removing
|
|
* the copyright notice or references to the Internet Society or other
|
|
* Internet organizations, except as needed for the purpose of
|
|
* developing Internet standards in which case the procedures for
|
|
* copyrights defined in the Internet Standards process must be
|
|
* followed, or as required to translate it into languages other than
|
|
* English.
|
|
*
|
|
* The limited permissions granted above are perpetual and will not be
|
|
* revoked by the Internet Society or its successors or assigns.
|
|
*
|
|
* This document and the information contained herein is provided on an
|
|
* "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
|
|
* TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
|
|
* BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
|
|
* HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
*
|
|
* @version $Id$
|
|
* @package squirrelmail
|
|
* @subpackage decode
|
|
*/
|
|
|
|
/**
|
|
* Decode koi8-u encoded strings
|
|
* @param string $string Encoded string
|
|
* @return string Decoded string
|
|
*/
|
|
function charset_decode_koi8_u ($string) {
|
|
global $default_charset;
|
|
|
|
if (strtolower($default_charset) == 'koi8-u')
|
|
return $string;
|
|
|
|
/* Only do the slow convert if there are 8-bit characters */
|
|
/* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
|
|
if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
|
|
return $string;
|
|
|
|
$koi8u = 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($koi8u), array_values($koi8u), $string);
|
|
|
|
return $string;
|
|
}
|
|
|
|
?>
|