/gui/tools/webmail/functions/decode/cp1255.php
https://github.com/BenBE/ispCP · PHP · 171 lines · 137 code · 6 blank · 28 comment · 1 complexity · d4f4adf4f426056ef432bed68715045f MD5 · raw file
- <?php
- /**
- * decode/cp1255.php
- *
- * This file contains cp1255 decoding function that is needed to read
- * cp1255 encoded mails in non-cp1255 locale.
- *
- * Original data taken from:
- * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT
- *
- * Name: cp1255 to Unicode table
- * Unicode version: 2.0
- * Table version: 2.01
- * Table format: Format A
- * Date: 1/7/2000
- * Contact: cpxlate@microsoft.com
- *
- * @copyright 2003-2011 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id: cp1255.php 14084 2011-01-06 02:44:03Z pdontthink $
- * @package squirrelmail
- * @subpackage decode
- */
- /**
- * Decode cp1255-encoded string
- * @param string $string Encoded string
- * @return string $string decoded string
- */
- function charset_decode_cp1255 ($string) {
- // don't do decoding when there are no 8bit symbols
- if (! sq_is8bit($string,'windows-1255'))
- return $string;
- $cp1255 = 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($cp1255), array_values($cp1255), $string);
- return $string;
- }