| 1 | <?php |
| 2 | /** |
| 3 | * decode/cp1257.php |
| 4 | * |
| 5 | * Copyright (c) 2003-2005 The SquirrelMail Project Team |
| 6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 7 | * |
| 8 | * This file contains cp1257 decoding function that is needed to read |
| 9 | * cp1257 encoded mails in non-cp1257 locale. |
| 10 | * |
| 11 | * Original data taken from: |
| 12 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1257.TXT |
| 13 | * |
| 14 | * Name: cp1257 to Unicode table |
| 15 | * Unicode version: 2.0 |
| 16 | * Table version: 2.01 |
| 17 | * Table format: Format A |
| 18 | * Date: 04/15/98 |
| 19 | * Contact: cpxlate@microsoft.com |
| 20 | * |
| 21 | * @version $Id$ |
| 22 | * @package squirrelmail |
| 23 | * @subpackage decode |
| 24 | */ |
| 25 | |
| 26 | /** |
| 27 | * Decode cp1257-encoded string |
| 28 | * @param string $string Encoded string |
| 29 | * @return string $string Decoded string |
| 30 | */ |
| 31 | function charset_decode_cp1257 ($string) { |
| 32 | // don't do decoding when there are no 8bit symbols |
| 33 | if (! sq_is8bit($string,'windows-1257')) |
| 34 | return $string; |
| 35 | |
| 36 | $cp1257 = array( |
| 37 | "\x80" => '€', |
| 38 | "\x82" => '‚', |
| 39 | "\x84" => '„', |
| 40 | "\x85" => '…', |
| 41 | "\x86" => '†', |
| 42 | "\x87" => '‡', |
| 43 | "\x89" => '‰', |
| 44 | "\x8B" => '‹', |
| 45 | "\x8D" => '¨', |
| 46 | "\x8E" => 'ˇ', |
| 47 | "\x8F" => '¸', |
| 48 | "\x91" => '‘', |
| 49 | "\x92" => '’', |
| 50 | "\x93" => '“', |
| 51 | "\x94" => '”', |
| 52 | "\x95" => '•', |
| 53 | "\x96" => '–', |
| 54 | "\x97" => '—', |
| 55 | "\x99" => '™', |
| 56 | "\x9B" => '›', |
| 57 | "\x9D" => '¯', |
| 58 | "\x9E" => '˛', |
| 59 | "\xA0" => ' ', |
| 60 | "\xA2" => '¢', |
| 61 | "\xA3" => '£', |
| 62 | "\xA4" => '¤', |
| 63 | "\xA6" => '¦', |
| 64 | "\xA7" => '§', |
| 65 | "\xA8" => 'Ø', |
| 66 | "\xA9" => '©', |
| 67 | "\xAA" => 'Ŗ', |
| 68 | "\xAB" => '«', |
| 69 | "\xAC" => '¬', |
| 70 | "\xAD" => '­', |
| 71 | "\xAE" => '®', |
| 72 | "\xAF" => 'Æ', |
| 73 | "\xB0" => '°', |
| 74 | "\xB1" => '±', |
| 75 | "\xB2" => '²', |
| 76 | "\xB3" => '³', |
| 77 | "\xB4" => '´', |
| 78 | "\xB5" => 'µ', |
| 79 | "\xB6" => '¶', |
| 80 | "\xB7" => '·', |
| 81 | "\xB8" => 'ø', |
| 82 | "\xB9" => '¹', |
| 83 | "\xBA" => 'ŗ', |
| 84 | "\xBB" => '»', |
| 85 | "\xBC" => '¼', |
| 86 | "\xBD" => '½', |
| 87 | "\xBE" => '¾', |
| 88 | "\xBF" => 'æ', |
| 89 | "\xC0" => 'Ą', |
| 90 | "\xC1" => 'Į', |
| 91 | "\xC2" => 'Ā', |
| 92 | "\xC3" => 'Ć', |
| 93 | "\xC4" => 'Ä', |
| 94 | "\xC5" => 'Å', |
| 95 | "\xC6" => 'Ę', |
| 96 | "\xC7" => 'Ē', |
| 97 | "\xC8" => 'Č', |
| 98 | "\xC9" => 'É', |
| 99 | "\xCA" => 'Ź', |
| 100 | "\xCB" => 'Ė', |
| 101 | "\xCC" => 'Ģ', |
| 102 | "\xCD" => 'Ķ', |
| 103 | "\xCE" => 'Ī', |
| 104 | "\xCF" => 'Ļ', |
| 105 | "\xD0" => 'Š', |
| 106 | "\xD1" => 'Ń', |
| 107 | "\xD2" => 'Ņ', |
| 108 | "\xD3" => 'Ó', |
| 109 | "\xD4" => 'Ō', |
| 110 | "\xD5" => 'Õ', |
| 111 | "\xD6" => 'Ö', |
| 112 | "\xD7" => '×', |
| 113 | "\xD8" => 'Ų', |
| 114 | "\xD9" => 'Ł', |
| 115 | "\xDA" => 'Ś', |
| 116 | "\xDB" => 'Ū', |
| 117 | "\xDC" => 'Ü', |
| 118 | "\xDD" => 'Ż', |
| 119 | "\xDE" => 'Ž', |
| 120 | "\xDF" => 'ß', |
| 121 | "\xE0" => 'ą', |
| 122 | "\xE1" => 'į', |
| 123 | "\xE2" => 'ā', |
| 124 | "\xE3" => 'ć', |
| 125 | "\xE4" => 'ä', |
| 126 | "\xE5" => 'å', |
| 127 | "\xE6" => 'ę', |
| 128 | "\xE7" => 'ē', |
| 129 | "\xE8" => 'č', |
| 130 | "\xE9" => 'é', |
| 131 | "\xEA" => 'ź', |
| 132 | "\xEB" => 'ė', |
| 133 | "\xEC" => 'ģ', |
| 134 | "\xED" => 'ķ', |
| 135 | "\xEE" => 'ī', |
| 136 | "\xEF" => 'ļ', |
| 137 | "\xF0" => 'š', |
| 138 | "\xF1" => 'ń', |
| 139 | "\xF2" => 'ņ', |
| 140 | "\xF3" => 'ó', |
| 141 | "\xF4" => 'ō', |
| 142 | "\xF5" => 'õ', |
| 143 | "\xF6" => 'ö', |
| 144 | "\xF7" => '÷', |
| 145 | "\xF8" => 'ų', |
| 146 | "\xF9" => 'ł', |
| 147 | "\xFA" => 'ś', |
| 148 | "\xFB" => 'ū', |
| 149 | "\xFC" => 'ü', |
| 150 | "\xFD" => 'ż', |
| 151 | "\xFE" => 'ž', |
| 152 | "\xFF" => '˙' |
| 153 | ); |
| 154 | |
| 155 | $string = str_replace(array_keys($cp1257), array_values($cp1257), $string); |
| 156 | |
| 157 | return $string; |
| 158 | } |
| 159 | |
| 160 | ?> |