178 lines
4 KiB
PHP
178 lines
4 KiB
PHP
<?php
|
|
/**
|
|
* decode/cp1256.php
|
|
*
|
|
* Copyright (c) 2003-2004 The SquirrelMail Project Team
|
|
* Licensed under the GNU GPL. For full terms see the file COPYING.
|
|
*
|
|
* This file contains cp1256 decoding function that is needed to read
|
|
* cp1256 encoded mails in non-cp1256 locale.
|
|
*
|
|
* Original data taken from:
|
|
* ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT
|
|
*
|
|
* Name: cp1256 to Unicode table
|
|
* Unicode version: 2.1
|
|
* Table version: 2.01
|
|
* Table format: Format A
|
|
* Date: 01/5/99
|
|
* Contact: cpxlate@microsoft.com
|
|
*
|
|
* @version $Id$
|
|
* @package squirrelmail
|
|
* @subpackage decode
|
|
*/
|
|
|
|
/**
|
|
* decode cp1256-encoded string
|
|
* @param string $string Encoded string
|
|
* @return string $string Decoded string
|
|
*/
|
|
function charset_decode_cp1256 ($string) {
|
|
global $default_charset;
|
|
|
|
if (strtolower($default_charset) == 'windows-1256')
|
|
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;
|
|
|
|
$cp1256 = 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($cp1256), array_values($cp1256), $string);
|
|
|
|
return $string;
|
|
}
|
|
|
|
?>
|