/libs/functions/decode/cp1257.php
https://github.com/dslfaithdev/soEmail · PHP · 159 lines · 125 code · 6 blank · 28 comment · 1 complexity · 26aed57cac06864f538caddfc23c6f98 MD5 · raw file
- <?php
- /**
- * decode/cp1257.php
- *
- * This file contains cp1257 decoding function that is needed to read
- * cp1257 encoded mails in non-cp1257 locale.
- *
- * Original data taken from:
- * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1257.TXT
- *
- * Name: cp1257 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-2009 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id: cp1257.php 13549 2009-04-15 22:00:49Z jervfors $
- * @package squirrelmail
- * @subpackage decode
- */
- /**
- * Decode cp1257-encoded string
- * @param string $string Encoded string
- * @return string $string Decoded string
- */
- function charset_decode_cp1257 ($string) {
- // don't do decoding when there are no 8bit symbols
- if (! sq_is8bit($string,'windows-1257'))
- return $string;
- $cp1257 = array(
- "\x80" => '€',
- "\x82" => '‚',
- "\x84" => '„',
- "\x85" => '…',
- "\x86" => '†',
- "\x87" => '‡',
- "\x89" => '‰',
- "\x8B" => '‹',
- "\x8D" => '¨',
- "\x8E" => 'ˇ',
- "\x8F" => '¸',
- "\x91" => '‘',
- "\x92" => '’',
- "\x93" => '“',
- "\x94" => '”',
- "\x95" => '•',
- "\x96" => '–',
- "\x97" => '—',
- "\x99" => '™',
- "\x9B" => '›',
- "\x9D" => '¯',
- "\x9E" => '˛',
- "\xA0" => ' ',
- "\xA2" => '¢',
- "\xA3" => '£',
- "\xA4" => '¤',
- "\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($cp1257), array_values($cp1257), $string);
- return $string;
- }