| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * i18n.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * This file contains variuos functions that are needed to do |
| 10 | * internationalization of SquirrelMail. |
| 11 | * |
| 12 | * Internally the output character set is used. Other characters are |
| 13 | * encoded using Unicode entities according to HTML 4.0. |
| 14 | * |
| 15 | * $Id$ |
| 16 | */ |
| 17 | |
| 18 | /* Decodes a string to the internal encoding from the given charset */ |
| 19 | function charset_decode ($charset, $string) { |
| 20 | |
| 21 | /* All HTML special characters are 7 bit and can be replaced first */ |
| 22 | $string = htmlspecialchars ($string); |
| 23 | |
| 24 | $charset = strtolower($charset); |
| 25 | |
| 26 | if (ereg('iso-8859-([[:digit:]]+)', $charset, $res)) { |
| 27 | if ($res[1] == '1') { |
| 28 | $ret = charset_decode_iso_8859_1 ($string); |
| 29 | } else if ($res[1] == '2') { |
| 30 | $ret = charset_decode_iso_8859_2 ($string); |
| 31 | } else if ($res[1] == '7') { |
| 32 | $ret = charset_decode_iso_8859_7 ($string); |
| 33 | } else if ($res[1] == '15') { |
| 34 | $ret = charset_decode_iso_8859_15 ($string); |
| 35 | } else { |
| 36 | $ret = charset_decode_iso_8859_default ($string); |
| 37 | } |
| 38 | } else if ($charset == 'ns_4551-1') { |
| 39 | $ret = charset_decode_ns_4551_1 ($string); |
| 40 | } else if ($charset == 'koi8-r') { |
| 41 | $ret = charset_decode_koi8r ($string); |
| 42 | } else if ($charset == 'windows-1251') { |
| 43 | $ret = charset_decode_koi8r ($string); |
| 44 | } else { |
| 45 | $ret = $string; |
| 46 | } |
| 47 | return( $ret ); |
| 48 | } |
| 49 | |
| 50 | /* |
| 51 | iso-8859-1 is the same as Latin 1 and is normally used |
| 52 | in western europe. |
| 53 | */ |
| 54 | function charset_decode_iso_8859_1 ($string) { |
| 55 | global $default_charset; |
| 56 | |
| 57 | if (strtolower($default_charset) <> 'iso-8859-1') { |
| 58 | /* Only do the slow convert if there are 8-bit characters */ |
| 59 | if (ereg("[\200-\377]", $string)) { |
| 60 | $string = str_replace("\201", '', $string); |
| 61 | $string = str_replace("\202", '‚', $string); |
| 62 | $string = str_replace("\203", 'ƒ', $string); |
| 63 | $string = str_replace("\204", '„', $string); |
| 64 | $string = str_replace("\205", '…', $string); |
| 65 | $string = str_replace("\206", '†', $string); |
| 66 | $string = str_replace("\207", '‡', $string); |
| 67 | $string = str_replace("\210", 'ˆ', $string); |
| 68 | $string = str_replace("\211", '‰', $string); |
| 69 | $string = str_replace("\212", 'Š', $string); |
| 70 | $string = str_replace("\213", '‹', $string); |
| 71 | $string = str_replace("\214", 'Œ', $string); |
| 72 | $string = str_replace("\215", '', $string); |
| 73 | $string = str_replace("\216", 'Ž', $string); |
| 74 | $string = str_replace("\217", '', $string); |
| 75 | $string = str_replace("\220", '', $string); |
| 76 | $string = str_replace("\221", '‘', $string); |
| 77 | $string = str_replace("\222", '’', $string); |
| 78 | $string = str_replace("\223", '“', $string); |
| 79 | $string = str_replace("\224", '”', $string); |
| 80 | $string = str_replace("\225", '•', $string); |
| 81 | $string = str_replace("\226", '–', $string); |
| 82 | $string = str_replace("\227", '—', $string); |
| 83 | $string = str_replace("\230", '˜', $string); |
| 84 | $string = str_replace("\231", '™', $string); |
| 85 | $string = str_replace("\232", 'š', $string); |
| 86 | $string = str_replace("\233", '›', $string); |
| 87 | $string = str_replace("\234", 'œ', $string); |
| 88 | $string = str_replace("\235", '', $string); |
| 89 | $string = str_replace("\236", 'ž', $string); |
| 90 | $string = str_replace("\237", 'Ÿ', $string); |
| 91 | $string = str_replace("\240", ' ', $string); |
| 92 | $string = str_replace("\241", '¡', $string); |
| 93 | $string = str_replace("\242", '¢', $string); |
| 94 | $string = str_replace("\243", '£', $string); |
| 95 | $string = str_replace("\244", '¤', $string); |
| 96 | $string = str_replace("\245", '¥', $string); |
| 97 | $string = str_replace("\246", '¦', $string); |
| 98 | $string = str_replace("\247", '§', $string); |
| 99 | $string = str_replace("\250", '¨', $string); |
| 100 | $string = str_replace("\251", '©', $string); |
| 101 | $string = str_replace("\252", 'ª', $string); |
| 102 | $string = str_replace("\253", '«', $string); |
| 103 | $string = str_replace("\254", '¬', $string); |
| 104 | $string = str_replace("\255", '­', $string); |
| 105 | $string = str_replace("\256", '®', $string); |
| 106 | $string = str_replace("\257", '¯', $string); |
| 107 | $string = str_replace("\260", '°', $string); |
| 108 | $string = str_replace("\261", '±', $string); |
| 109 | $string = str_replace("\262", '²', $string); |
| 110 | $string = str_replace("\263", '³', $string); |
| 111 | $string = str_replace("\264", '´', $string); |
| 112 | $string = str_replace("\265", 'µ', $string); |
| 113 | $string = str_replace("\266", '¶', $string); |
| 114 | $string = str_replace("\267", '·', $string); |
| 115 | $string = str_replace("\270", '¸', $string); |
| 116 | $string = str_replace("\271", '¹', $string); |
| 117 | $string = str_replace("\272", 'º', $string); |
| 118 | $string = str_replace("\273", '»', $string); |
| 119 | $string = str_replace("\274", '¼', $string); |
| 120 | $string = str_replace("\275", '½', $string); |
| 121 | $string = str_replace("\276", '¾', $string); |
| 122 | $string = str_replace("\277", '¿', $string); |
| 123 | $string = str_replace("\300", 'À', $string); |
| 124 | $string = str_replace("\301", 'Á', $string); |
| 125 | $string = str_replace("\302", 'Â', $string); |
| 126 | $string = str_replace("\303", 'Ã', $string); |
| 127 | $string = str_replace("\304", 'Ä', $string); |
| 128 | $string = str_replace("\305", 'Å', $string); |
| 129 | $string = str_replace("\306", 'Æ', $string); |
| 130 | $string = str_replace("\307", 'Ç', $string); |
| 131 | $string = str_replace("\310", 'È', $string); |
| 132 | $string = str_replace("\311", 'É', $string); |
| 133 | $string = str_replace("\312", 'Ê', $string); |
| 134 | $string = str_replace("\313", 'Ë', $string); |
| 135 | $string = str_replace("\314", 'Ì', $string); |
| 136 | $string = str_replace("\315", 'Í', $string); |
| 137 | $string = str_replace("\316", 'Î', $string); |
| 138 | $string = str_replace("\317", 'Ï', $string); |
| 139 | $string = str_replace("\320", 'Ð', $string); |
| 140 | $string = str_replace("\321", 'Ñ', $string); |
| 141 | $string = str_replace("\322", 'Ò', $string); |
| 142 | $string = str_replace("\323", 'Ó', $string); |
| 143 | $string = str_replace("\324", 'Ô', $string); |
| 144 | $string = str_replace("\325", 'Õ', $string); |
| 145 | $string = str_replace("\326", 'Ö', $string); |
| 146 | $string = str_replace("\327", '×', $string); |
| 147 | $string = str_replace("\330", 'Ø', $string); |
| 148 | $string = str_replace("\331", 'Ù', $string); |
| 149 | $string = str_replace("\332", 'Ú', $string); |
| 150 | $string = str_replace("\333", 'Û', $string); |
| 151 | $string = str_replace("\334", 'Ü', $string); |
| 152 | $string = str_replace("\335", 'Ý', $string); |
| 153 | $string = str_replace("\336", 'Þ', $string); |
| 154 | $string = str_replace("\337", 'ß', $string); |
| 155 | $string = str_replace("\340", 'à', $string); |
| 156 | $string = str_replace("\341", 'á', $string); |
| 157 | $string = str_replace("\342", 'â', $string); |
| 158 | $string = str_replace("\343", 'ã', $string); |
| 159 | $string = str_replace("\344", 'ä', $string); |
| 160 | $string = str_replace("\345", 'å', $string); |
| 161 | $string = str_replace("\346", 'æ', $string); |
| 162 | $string = str_replace("\347", 'ç', $string); |
| 163 | $string = str_replace("\350", 'è', $string); |
| 164 | $string = str_replace("\351", 'é', $string); |
| 165 | $string = str_replace("\352", 'ê', $string); |
| 166 | $string = str_replace("\353", 'ë', $string); |
| 167 | $string = str_replace("\354", 'ì', $string); |
| 168 | $string = str_replace("\355", 'í', $string); |
| 169 | $string = str_replace("\356", 'î', $string); |
| 170 | $string = str_replace("\357", 'ï', $string); |
| 171 | $string = str_replace("\360", 'ð', $string); |
| 172 | $string = str_replace("\361", 'ñ', $string); |
| 173 | $string = str_replace("\362", 'ò', $string); |
| 174 | $string = str_replace("\363", 'ó', $string); |
| 175 | $string = str_replace("\364", 'ô', $string); |
| 176 | $string = str_replace("\365", 'õ', $string); |
| 177 | $string = str_replace("\366", 'ö', $string); |
| 178 | $string = str_replace("\367", '÷', $string); |
| 179 | $string = str_replace("\370", 'ø', $string); |
| 180 | $string = str_replace("\371", 'ù', $string); |
| 181 | $string = str_replace("\372", 'ú', $string); |
| 182 | $string = str_replace("\373", 'û', $string); |
| 183 | $string = str_replace("\374", 'ü', $string); |
| 184 | $string = str_replace("\375", 'ý', $string); |
| 185 | $string = str_replace("\376", 'þ', $string); |
| 186 | $string = str_replace("\377", 'ÿ', $string); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | return ($string); |
| 191 | } |
| 192 | |
| 193 | /* iso-8859-2 is used for some eastern European languages */ |
| 194 | function charset_decode_iso_8859_2 ($string) { |
| 195 | global $default_charset; |
| 196 | |
| 197 | if (strtolower($default_charset) == 'iso-8859-2') |
| 198 | return $string; |
| 199 | |
| 200 | /* Only do the slow convert if there are 8-bit characters */ |
| 201 | if (! ereg("[\200-\377]", $string)) |
| 202 | return $string; |
| 203 | |
| 204 | /* NO-BREAK SPACE */ |
| 205 | $string = str_replace("\240", ' ', $string); |
| 206 | /* LATIN CAPITAL LETTER A WITH OGONEK */ |
| 207 | $string = str_replace("\241", 'Ą', $string); |
| 208 | /* BREVE */ |
| 209 | $string = str_replace("\242", '˘', $string); |
| 210 | // LATIN CAPITAL LETTER L WITH STROKE |
| 211 | $string = str_replace("\243", 'Ł', $string); |
| 212 | // CURRENCY SIGN |
| 213 | $string = str_replace("\244", '¤', $string); |
| 214 | // LATIN CAPITAL LETTER L WITH CARON |
| 215 | $string = str_replace("\245", 'Ľ', $string); |
| 216 | // LATIN CAPITAL LETTER S WITH ACUTE |
| 217 | $string = str_replace("\246", 'Ś', $string); |
| 218 | // SECTION SIGN |
| 219 | $string = str_replace("\247", '§', $string); |
| 220 | // DIAERESIS |
| 221 | $string = str_replace("\250", '¨', $string); |
| 222 | // LATIN CAPITAL LETTER S WITH CARON |
| 223 | $string = str_replace("\251", 'Š', $string); |
| 224 | // LATIN CAPITAL LETTER S WITH CEDILLA |
| 225 | $string = str_replace("\252", 'Ş', $string); |
| 226 | // LATIN CAPITAL LETTER T WITH CARON |
| 227 | $string = str_replace("\253", 'Ť', $string); |
| 228 | // LATIN CAPITAL LETTER Z WITH ACUTE |
| 229 | $string = str_replace("\254", 'Ź', $string); |
| 230 | // SOFT HYPHEN |
| 231 | $string = str_replace("\255", '­', $string); |
| 232 | // LATIN CAPITAL LETTER Z WITH CARON |
| 233 | $string = str_replace("\256", 'Ž', $string); |
| 234 | // LATIN CAPITAL LETTER Z WITH DOT ABOVE |
| 235 | $string = str_replace("\257", 'Ż', $string); |
| 236 | // DEGREE SIGN |
| 237 | $string = str_replace("\260", '°', $string); |
| 238 | // LATIN SMALL LETTER A WITH OGONEK |
| 239 | $string = str_replace("\261", 'ą', $string); |
| 240 | // OGONEK |
| 241 | $string = str_replace("\262", '˛', $string); |
| 242 | // LATIN SMALL LETTER L WITH STROKE |
| 243 | $string = str_replace("\263", 'ł', $string); |
| 244 | // ACUTE ACCENT |
| 245 | $string = str_replace("\264", '´', $string); |
| 246 | // LATIN SMALL LETTER L WITH CARON |
| 247 | $string = str_replace("\265", 'ľ', $string); |
| 248 | // LATIN SMALL LETTER S WITH ACUTE |
| 249 | $string = str_replace("\266", 'ś', $string); |
| 250 | // CARON |
| 251 | $string = str_replace("\267", 'ˇ', $string); |
| 252 | // CEDILLA |
| 253 | $string = str_replace("\270", '¸', $string); |
| 254 | // LATIN SMALL LETTER S WITH CARON |
| 255 | $string = str_replace("\271", 'š', $string); |
| 256 | // LATIN SMALL LETTER S WITH CEDILLA |
| 257 | $string = str_replace("\272", 'ş', $string); |
| 258 | // LATIN SMALL LETTER T WITH CARON |
| 259 | $string = str_replace("\273", 'ť', $string); |
| 260 | // LATIN SMALL LETTER Z WITH ACUTE |
| 261 | $string = str_replace("\274", 'ź', $string); |
| 262 | // DOUBLE ACUTE ACCENT |
| 263 | $string = str_replace("\275", '˝', $string); |
| 264 | // LATIN SMALL LETTER Z WITH CARON |
| 265 | $string = str_replace("\276", 'ž', $string); |
| 266 | // LATIN SMALL LETTER Z WITH DOT ABOVE |
| 267 | $string = str_replace("\277", 'ż', $string); |
| 268 | // LATIN CAPITAL LETTER R WITH ACUTE |
| 269 | $string = str_replace("\300", 'Ŕ', $string); |
| 270 | // LATIN CAPITAL LETTER A WITH ACUTE |
| 271 | $string = str_replace("\301", 'Á', $string); |
| 272 | // LATIN CAPITAL LETTER A WITH CIRCUMFLEX |
| 273 | $string = str_replace("\302", 'Â', $string); |
| 274 | // LATIN CAPITAL LETTER A WITH BREVE |
| 275 | $string = str_replace("\303", 'Ă', $string); |
| 276 | // LATIN CAPITAL LETTER A WITH DIAERESIS |
| 277 | $string = str_replace("\304", 'Ä', $string); |
| 278 | // LATIN CAPITAL LETTER L WITH ACUTE |
| 279 | $string = str_replace("\305", 'Ĺ', $string); |
| 280 | // LATIN CAPITAL LETTER C WITH ACUTE |
| 281 | $string = str_replace("\306", 'Ć', $string); |
| 282 | // LATIN CAPITAL LETTER C WITH CEDILLA |
| 283 | $string = str_replace("\307", 'Ç', $string); |
| 284 | // LATIN CAPITAL LETTER C WITH CARON |
| 285 | $string = str_replace("\310", 'Č', $string); |
| 286 | // LATIN CAPITAL LETTER E WITH ACUTE |
| 287 | $string = str_replace("\311", 'É', $string); |
| 288 | // LATIN CAPITAL LETTER E WITH OGONEK |
| 289 | $string = str_replace("\312", 'Ę', $string); |
| 290 | // LATIN CAPITAL LETTER E WITH DIAERESIS |
| 291 | $string = str_replace("\313", 'Ë', $string); |
| 292 | // LATIN CAPITAL LETTER E WITH CARON |
| 293 | $string = str_replace("\314", 'Ě', $string); |
| 294 | // LATIN CAPITAL LETTER I WITH ACUTE |
| 295 | $string = str_replace("\315", 'Í', $string); |
| 296 | // LATIN CAPITAL LETTER I WITH CIRCUMFLEX |
| 297 | $string = str_replace("\316", 'Î', $string); |
| 298 | // LATIN CAPITAL LETTER D WITH CARON |
| 299 | $string = str_replace("\317", 'Ď', $string); |
| 300 | // LATIN CAPITAL LETTER D WITH STROKE |
| 301 | $string = str_replace("\320", 'Đ', $string); |
| 302 | // LATIN CAPITAL LETTER N WITH ACUTE |
| 303 | $string = str_replace("\321", 'Ń', $string); |
| 304 | // LATIN CAPITAL LETTER N WITH CARON |
| 305 | $string = str_replace("\322", 'Ň', $string); |
| 306 | // LATIN CAPITAL LETTER O WITH ACUTE |
| 307 | $string = str_replace("\323", 'Ó', $string); |
| 308 | // LATIN CAPITAL LETTER O WITH CIRCUMFLEX |
| 309 | $string = str_replace("\324", 'Ô', $string); |
| 310 | // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE |
| 311 | $string = str_replace("\325", 'Ő', $string); |
| 312 | // LATIN CAPITAL LETTER O WITH DIAERESIS |
| 313 | $string = str_replace("\326", 'Ö', $string); |
| 314 | // MULTIPLICATION SIGN |
| 315 | $string = str_replace("\327", '×', $string); |
| 316 | // LATIN CAPITAL LETTER R WITH CARON |
| 317 | $string = str_replace("\330", 'Ř', $string); |
| 318 | // LATIN CAPITAL LETTER U WITH RING ABOVE |
| 319 | $string = str_replace("\331", 'Ů', $string); |
| 320 | // LATIN CAPITAL LETTER U WITH ACUTE |
| 321 | $string = str_replace("\332", 'Ú', $string); |
| 322 | // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE |
| 323 | $string = str_replace("\333", 'Ű', $string); |
| 324 | // LATIN CAPITAL LETTER U WITH DIAERESIS |
| 325 | $string = str_replace("\334", 'Ü', $string); |
| 326 | // LATIN CAPITAL LETTER Y WITH ACUTE |
| 327 | $string = str_replace("\335", 'Ý', $string); |
| 328 | // LATIN CAPITAL LETTER T WITH CEDILLA |
| 329 | $string = str_replace("\336", 'Ţ', $string); |
| 330 | // LATIN SMALL LETTER SHARP S |
| 331 | $string = str_replace("\337", 'ß', $string); |
| 332 | // LATIN SMALL LETTER R WITH ACUTE |
| 333 | $string = str_replace("\340", 'ŕ', $string); |
| 334 | // LATIN SMALL LETTER A WITH ACUTE |
| 335 | $string = str_replace("\341", 'á', $string); |
| 336 | // LATIN SMALL LETTER A WITH CIRCUMFLEX |
| 337 | $string = str_replace("\342", 'â', $string); |
| 338 | // LATIN SMALL LETTER A WITH BREVE |
| 339 | $string = str_replace("\343", 'ă', $string); |
| 340 | // LATIN SMALL LETTER A WITH DIAERESIS |
| 341 | $string = str_replace("\344", 'ä', $string); |
| 342 | // LATIN SMALL LETTER L WITH ACUTE |
| 343 | $string = str_replace("\345", 'ĺ', $string); |
| 344 | // LATIN SMALL LETTER C WITH ACUTE |
| 345 | $string = str_replace("\346", 'ć', $string); |
| 346 | // LATIN SMALL LETTER C WITH CEDILLA |
| 347 | $string = str_replace("\347", 'ç', $string); |
| 348 | // LATIN SMALL LETTER C WITH CARON |
| 349 | $string = str_replace("\350", 'č', $string); |
| 350 | // LATIN SMALL LETTER E WITH ACUTE |
| 351 | $string = str_replace("\351", 'é', $string); |
| 352 | // LATIN SMALL LETTER E WITH OGONEK |
| 353 | $string = str_replace("\352", 'ę', $string); |
| 354 | // LATIN SMALL LETTER E WITH DIAERESIS |
| 355 | $string = str_replace("\353", 'ë', $string); |
| 356 | // LATIN SMALL LETTER E WITH CARON |
| 357 | $string = str_replace("\354", 'ě', $string); |
| 358 | // LATIN SMALL LETTER I WITH ACUTE |
| 359 | $string = str_replace("\355", 'í', $string); |
| 360 | // LATIN SMALL LETTER I WITH CIRCUMFLEX |
| 361 | $string = str_replace("\356", 'î', $string); |
| 362 | // LATIN SMALL LETTER D WITH CARON |
| 363 | $string = str_replace("\357", 'ď', $string); |
| 364 | // LATIN SMALL LETTER D WITH STROKE |
| 365 | $string = str_replace("\360", 'đ', $string); |
| 366 | // LATIN SMALL LETTER N WITH ACUTE |
| 367 | $string = str_replace("\361", 'ń', $string); |
| 368 | // LATIN SMALL LETTER N WITH CARON |
| 369 | $string = str_replace("\362", 'ň', $string); |
| 370 | // LATIN SMALL LETTER O WITH ACUTE |
| 371 | $string = str_replace("\363", 'ó', $string); |
| 372 | // LATIN SMALL LETTER O WITH CIRCUMFLEX |
| 373 | $string = str_replace("\364", 'ô', $string); |
| 374 | // LATIN SMALL LETTER O WITH DOUBLE ACUTE |
| 375 | $string = str_replace("\365", 'ő', $string); |
| 376 | // LATIN SMALL LETTER O WITH DIAERESIS |
| 377 | $string = str_replace("\366", 'ö', $string); |
| 378 | // DIVISION SIGN |
| 379 | $string = str_replace("\367", '÷', $string); |
| 380 | // LATIN SMALL LETTER R WITH CARON |
| 381 | $string = str_replace("\370", 'ř', $string); |
| 382 | // LATIN SMALL LETTER U WITH RING ABOVE |
| 383 | $string = str_replace("\371", 'ů', $string); |
| 384 | // LATIN SMALL LETTER U WITH ACUTE |
| 385 | $string = str_replace("\372", 'ú', $string); |
| 386 | // LATIN SMALL LETTER U WITH DOUBLE ACUTE |
| 387 | $string = str_replace("\373", 'ű', $string); |
| 388 | // LATIN SMALL LETTER U WITH DIAERESIS |
| 389 | $string = str_replace("\374", 'ü', $string); |
| 390 | // LATIN SMALL LETTER Y WITH ACUTE |
| 391 | $string = str_replace("\375", 'ý', $string); |
| 392 | // LATIN SMALL LETTER T WITH CEDILLA |
| 393 | $string = str_replace("\376", 'ţ', $string); |
| 394 | // DOT ABOVE |
| 395 | $string = str_replace("\377", '˙', $string); |
| 396 | |
| 397 | return $string; |
| 398 | } |
| 399 | |
| 400 | /* iso-8859-7 is Greek. */ |
| 401 | function charset_decode_iso_8859_7 ($string) { |
| 402 | global $default_charset; |
| 403 | |
| 404 | if (strtolower($default_charset) == 'iso-8859-7') { |
| 405 | return $string; |
| 406 | } |
| 407 | |
| 408 | /* Only do the slow convert if there are 8-bit characters */ |
| 409 | if (!ereg("[\200-\377]", $string)) { |
| 410 | return $string; |
| 411 | } |
| 412 | |
| 413 | /* Some diverse characters in the beginning */ |
| 414 | $string = str_replace("\240", ' ', $string); |
| 415 | $string = str_replace("\241", '‘', $string); |
| 416 | $string = str_replace("\242", '’', $string); |
| 417 | $string = str_replace("\243", '£', $string); |
| 418 | $string = str_replace("\246", '¦', $string); |
| 419 | $string = str_replace("\247", '§', $string); |
| 420 | $string = str_replace("\250", '¨', $string); |
| 421 | $string = str_replace("\251", '©', $string); |
| 422 | $string = str_replace("\253", '«', $string); |
| 423 | $string = str_replace("\254", '¬', $string); |
| 424 | $string = str_replace("\255", '­', $string); |
| 425 | $string = str_replace("\257", '―', $string); |
| 426 | $string = str_replace("\260", '°', $string); |
| 427 | $string = str_replace("\261", '±', $string); |
| 428 | $string = str_replace("\262", '²', $string); |
| 429 | $string = str_replace("\263", '³', $string); |
| 430 | |
| 431 | /* Horizontal bar (parentheki pavla) */ |
| 432 | $string = str_replace ("\257", '―', $string); |
| 433 | |
| 434 | /* |
| 435 | * ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6) |
| 436 | * These are Unicode 900-902 |
| 437 | */ |
| 438 | $string = preg_replace("/([\264-\266])/","'&#' . (ord(\\1)+720)",$string); |
| 439 | |
| 440 | /* 11/07 (0xB7) Middle dot is the same in iso-8859-1 */ |
| 441 | $string = str_replace("\267", '·', $string); |
| 442 | |
| 443 | /* |
| 444 | * ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA) |
| 445 | * These are Unicode 900-902 |
| 446 | */ |
| 447 | $string = preg_replace("/([\270-\272])/","'&#' . (ord(\\1)+720)",$string); |
| 448 | |
| 449 | /* |
| 450 | * 11/11 (0xBB) Right angle quotation mark is the same as in |
| 451 | * iso-8859-1 |
| 452 | */ |
| 453 | $string = str_replace("\273", '»', $string); |
| 454 | |
| 455 | /* And now the rest of the charset */ |
| 456 | $string = preg_replace("/([\274-\376])/","'&#' . (ord(\\1)+720)",$string); |
| 457 | |
| 458 | return $string; |
| 459 | } |
| 460 | |
| 461 | /* |
| 462 | * iso-8859-15 is Latin 9 and has very much the same use as Latin 1 |
| 463 | * but has the Euro symbol and some characters needed for French. |
| 464 | */ |
| 465 | function charset_decode_iso_8859_15 ($string) { |
| 466 | // Euro sign |
| 467 | $string = str_replace ("\244", '€', $string); |
| 468 | // Latin capital letter S with caron |
| 469 | $string = str_replace ("\246", 'Š', $string); |
| 470 | // Latin small letter s with caron |
| 471 | $string = str_replace ("\250", 'š', $string); |
| 472 | // Latin capital letter Z with caron |
| 473 | $string = str_replace ("\264", 'Ž', $string); |
| 474 | // Latin small letter z with caron |
| 475 | $string = str_replace ("\270", 'ž', $string); |
| 476 | // Latin capital ligature OE |
| 477 | $string = str_replace ("\274", 'Œ', $string); |
| 478 | // Latin small ligature oe |
| 479 | $string = str_replace ("\275", 'œ', $string); |
| 480 | // Latin capital letter Y with diaeresis |
| 481 | $string = str_replace ("\276", 'Ÿ', $string); |
| 482 | |
| 483 | return (charset_decode_iso_8859_1($string)); |
| 484 | } |
| 485 | |
| 486 | /* ISO-8859-5 is Cyrillic */ |
| 487 | function charset_decode_iso_8859_5 ($string) { |
| 488 | // Convert to KOI8-R, then return this decoded. |
| 489 | $string = convert_cyr_string($string, 'i', 'k'); |
| 490 | return charset_decode_koi8r($string); |
| 491 | } |
| 492 | |
| 493 | /* Remove all 8 bit characters from all other ISO-8859 character sets */ |
| 494 | function charset_decode_iso_8859_default ($string) { |
| 495 | return (strtr($string, "\240\241\242\243\244\245\246\247". |
| 496 | "\250\251\252\253\254\255\256\257". |
| 497 | "\260\261\262\263\264\265\266\267". |
| 498 | "\270\271\272\273\274\275\276\277". |
| 499 | "\300\301\302\303\304\305\306\307". |
| 500 | "\310\311\312\313\314\315\316\317". |
| 501 | "\320\321\322\323\324\325\326\327". |
| 502 | "\330\331\332\333\334\335\336\337". |
| 503 | "\340\341\342\343\344\345\346\347". |
| 504 | "\350\351\352\353\354\355\356\357". |
| 505 | "\360\361\362\363\364\365\366\367". |
| 506 | "\370\371\372\373\374\375\376\377", |
| 507 | "????????????????????????????????????????". |
| 508 | "????????????????????????????????????????". |
| 509 | "????????????????????????????????????????". |
| 510 | "????????")); |
| 511 | |
| 512 | } |
| 513 | |
| 514 | /* |
| 515 | * This is the same as ISO-646-NO and is used by some |
| 516 | * Microsoft programs when sending Norwegian characters |
| 517 | */ |
| 518 | function charset_decode_ns_4551_1 ($string) { |
| 519 | /* |
| 520 | * These characters are: |
| 521 | * Latin capital letter AE |
| 522 | * Latin capital letter O with stroke |
| 523 | * Latin capital letter A with ring above |
| 524 | * and the same as small letters |
| 525 | */ |
| 526 |