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