| 1 | <?php |
| 2 | /** |
| 3 | * decode/cp1258.php |
| 4 | * |
| 5 | * Copyright (c) 2003-2004 The SquirrelMail Project Team |
| 6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 7 | * |
| 8 | * This file contains cp1258 decoding function that is needed to read |
| 9 | * cp1258 encoded mails in non-cp1258 locale. |
| 10 | * |
| 11 | * Original data taken from: |
| 12 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1258.TXT |
| 13 | * |
| 14 | * Name: cp1258 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 | * Decde a cp1258-encoded string |
| 28 | * @param string $string Encoded string |
| 29 | * @return string $string Decoded string |
| 30 | */ |
| 31 | function charset_decode_cp1258 ($string) { |
| 32 | global $default_charset; |
| 33 | |
| 34 | if (strtolower($default_charset) == 'windows-1258') |
| 35 | return $string; |
| 36 | |
| 37 | // don't do decoding when there are no 8bit symbols |
| 38 | if (! sq_is8bit($string,'windows-1258')) |
| 39 | return $string; |
| 40 | |
| 41 | $cp1258 = array( |
| 42 | "\x80" => '€', |
| 43 | "\x81" => '�', |
| 44 | "\x82" => '‚', |
| 45 | "\x83" => 'ƒ', |
| 46 | "\x84" => '„', |
| 47 | "\x85" => '…', |
| 48 | "\x86" => '†', |
| 49 | "\x87" => '‡', |
| 50 | "\x88" => 'ˆ', |
| 51 | "\x89" => '‰', |
| 52 | "\x8A" => '�', |
| 53 | "\x8B" => '‹', |
| 54 | "\x8C" => 'Œ', |
| 55 | "\x8D" => '�', |
| 56 | "\x8E" => '�', |
| 57 | "\x8F" => '�', |
| 58 | "\x90" => '�', |
| 59 | "\x91" => '‘', |
| 60 | "\x92" => '’', |
| 61 | "\x93" => '“', |
| 62 | "\x94" => '”', |
| 63 | "\x95" => '•', |
| 64 | "\x96" => '–', |
| 65 | "\x97" => '—', |
| 66 | "\x98" => '˜', |
| 67 | "\x99" => '™', |
| 68 | "\x9A" => '�', |
| 69 | "\x9B" => '›', |
| 70 | "\x9C" => 'œ', |
| 71 | "\x9D" => '�', |
| 72 | "\x9E" => '�', |
| 73 | "\x9F" => 'Ÿ', |
| 74 | "\xA0" => ' ', |
| 75 | "\xA1" => '¡', |
| 76 | "\xA2" => '¢', |
| 77 | "\xA3" => '£', |
| 78 | "\xA4" => '¤', |
| 79 | "\xA5" => '¥', |
| 80 | "\xA6" => '¦', |
| 81 | "\xA7" => '§', |
| 82 | "\xA8" => '¨', |
| 83 | "\xA9" => '©', |
| 84 | "\xAA" => 'ª', |
| 85 | "\xAB" => '«', |
| 86 | "\xAC" => '¬', |
| 87 | "\xAD" => '­', |
| 88 | "\xAE" => '®', |
| 89 | "\xAF" => '¯', |
| 90 | "\xB0" => '°', |
| 91 | "\xB1" => '±', |
| 92 | "\xB2" => '²', |
| 93 | "\xB3" => '³', |
| 94 | "\xB4" => '´', |
| 95 | "\xB5" => 'µ', |
| 96 | "\xB6" => '¶', |
| 97 | "\xB7" => '·', |
| 98 | "\xB8" => '¸', |
| 99 | "\xB9" => '¹', |
| 100 | "\xBA" => 'º', |
| 101 | "\xBB" => '»', |
| 102 | "\xBC" => '¼', |
| 103 | "\xBD" => '½', |
| 104 | "\xBE" => '¾', |
| 105 | "\xBF" => '¿', |
| 106 | "\xC0" => 'À', |
| 107 | "\xC1" => 'Á', |
| 108 | "\xC2" => 'Â', |
| 109 | "\xC3" => 'Ă', |
| 110 | "\xC4" => 'Ä', |
| 111 | "\xC5" => 'Å', |
| 112 | "\xC6" => 'Æ', |
| 113 | "\xC7" => 'Ç', |
| 114 | "\xC8" => 'È', |
| 115 | "\xC9" => 'É', |
| 116 | "\xCA" => 'Ê', |
| 117 | "\xCB" => 'Ë', |
| 118 | "\xCC" => '̀', |
| 119 | "\xCD" => 'Í', |
| 120 | "\xCE" => 'Î', |
| 121 | "\xCF" => 'Ï', |
| 122 | "\xD0" => 'Đ', |
| 123 | "\xD1" => 'Ñ', |
| 124 | "\xD2" => '̉', |
| 125 | "\xD3" => 'Ó', |
| 126 | "\xD4" => 'Ô', |
| 127 | "\xD5" => 'Ơ', |
| 128 | "\xD6" => 'Ö', |
| 129 | "\xD7" => '×', |
| 130 | "\xD8" => 'Ø', |
| 131 | "\xD9" => 'Ù', |
| 132 | "\xDA" => 'Ú', |
| 133 | "\xDB" => 'Û', |
| 134 | "\xDC" => 'Ü', |
| 135 | "\xDD" => 'Ư', |
| 136 | "\xDE" => '̃', |
| 137 | "\xDF" => 'ß', |
| 138 | "\xE0" => 'à', |
| 139 | "\xE1" => 'á', |
| 140 | "\xE2" => 'â', |
| 141 | "\xE3" => 'ă', |
| 142 | "\xE4" => 'ä', |
| 143 | "\xE5" => 'å', |
| 144 | "\xE6" => 'æ', |
| 145 | "\xE7" => 'ç', |
| 146 | "\xE8" => 'è', |
| 147 | "\xE9" => 'é', |
| 148 | "\xEA" => 'ê', |
| 149 | "\xEB" => 'ë', |
| 150 | "\xEC" => '́', |
| 151 | "\xED" => 'í', |
| 152 | "\xEE" => 'î', |
| 153 | "\xEF" => 'ï', |
| 154 | "\xF0" => 'đ', |
| 155 | "\xF1" => 'ñ', |
| 156 | "\xF2" => '̣', |
| 157 | "\xF3" => 'ó', |
| 158 | "\xF4" => 'ô', |
| 159 | "\xF5" => 'ơ', |
| 160 | "\xF6" => 'ö', |
| 161 | "\xF7" => '÷', |
| 162 | "\xF8" => 'ø', |
| 163 | "\xF9" => 'ù', |
| 164 | "\xFA" => 'ú', |
| 165 | "\xFB" => 'û', |
| 166 | "\xFC" => 'ü', |
| 167 | "\xFD" => 'ư', |
| 168 | "\xFE" => '₫', |
| 169 | "\xFF" => 'ÿ' |
| 170 | ); |
| 171 | |
| 172 | $string = str_replace(array_keys($cp1258), array_values($cp1258), $string); |
| 173 | |
| 174 | return $string; |
| 175 | } |
| 176 | |
| 177 | ?> |