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