| 1 | <?php |
| 2 | /* |
| 3 | * decode/iso8859-15.php |
| 4 | * $Id$ |
| 5 | * |
| 6 | * Copyright (c) 1999-2003 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * This file contains iso-8859-15 decoding function that is needed to read |
| 10 | * iso-8859-15 encoded mails in non-iso-8859-15 locale. |
| 11 | * |
| 12 | * Original data taken from: |
| 13 | * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-15.TXT |
| 14 | * |
| 15 | * Name: ISO/IEC 8859-15:1999 to Unicode |
| 16 | * Unicode version: 3.0 |
| 17 | * Table version: 1.0 |
| 18 | * Table format: Format A |
| 19 | * Date: 1999 July 27 |
| 20 | * Authors: Markus Kuhn <mkuhn@acm.org> |
| 21 | * Ken Whistler <kenw@sybase.com> |
| 22 | * |
| 23 | * Original copyright: |
| 24 | * Copyright (c) 1999 Unicode, Inc. All Rights reserved. |
| 25 | * |
| 26 | * This file is provided as-is by Unicode, Inc. (The Unicode Consortium). |
| 27 | * No claims are made as to fitness for any particular purpose. No |
| 28 | * warranties of any kind are expressed or implied. The recipient |
| 29 | * agrees to determine applicability of information provided. If this |
| 30 | * file has been provided on optical media by Unicode, Inc., the sole |
| 31 | * remedy for any claim will be exchange of defective media within 90 |
| 32 | * days of receipt. |
| 33 | * |
| 34 | * Unicode, Inc. hereby grants the right to freely use the information |
| 35 | * supplied in this file in the creation of products supporting the |
| 36 | * Unicode Standard, and to make copies of this file in any form for |
| 37 | * internal or external distribution as long as this notice remains |
| 38 | * attached. |
| 39 | * |
| 40 | */ |
| 41 | function charset_decode_iso8859_15 ($string) { |
| 42 | global $default_charset; |
| 43 | |
| 44 | if (strtolower($default_charset) == 'iso-8859-15') |
| 45 | return $string; |
| 46 | |
| 47 | /* Only do the slow convert if there are 8-bit characters */ |
| 48 | /* there is no 0x80-0x9F letters in ISO8859-* */ |
| 49 | if ( ! ereg("[\241-\377]", $string) ) |
| 50 | return $string; |
| 51 | |
| 52 | $iso8859_15 = array( |
| 53 | "\xA0" => ' ', |
| 54 | "\xA1" => '¡', |
| 55 | "\xA2" => '¢', |
| 56 | "\xA3" => '£', |
| 57 | "\xA4" => '€', |
| 58 | "\xA5" => '¥', |
| 59 | "\xA6" => 'Š', |
| 60 | "\xA7" => '§', |
| 61 | "\xA8" => 'š', |
| 62 | "\xA9" => '©', |
| 63 | "\xAA" => 'ª', |
| 64 | "\xAB" => '«', |
| 65 | "\xAC" => '¬', |
| 66 | "\xAD" => '­', |
| 67 | "\xAE" => '®', |
| 68 | "\xAF" => '¯', |
| 69 | "\xB0" => '°', |
| 70 | "\xB1" => '±', |
| 71 | "\xB2" => '²', |
| 72 | "\xB3" => '³', |
| 73 | "\xB4" => 'Ž', |
| 74 | "\xB5" => 'µ', |
| 75 | "\xB6" => '¶', |
| 76 | "\xB7" => '·', |
| 77 | "\xB8" => 'ž', |
| 78 | "\xB9" => '¹', |
| 79 | "\xBA" => 'º', |
| 80 | "\xBB" => '»', |
| 81 | "\xBC" => 'Œ', |
| 82 | "\xBD" => 'œ', |
| 83 | "\xBE" => 'Ÿ', |
| 84 | "\xBF" => '¿', |
| 85 | "\xC0" => 'À', |
| 86 | "\xC1" => 'Á', |
| 87 | "\xC2" => 'Â', |
| 88 | "\xC3" => 'Ã', |
| 89 | "\xC4" => 'Ä', |
| 90 | "\xC5" => 'Å', |
| 91 | "\xC6" => 'Æ', |
| 92 | "\xC7" => 'Ç', |
| 93 | "\xC8" => 'È', |
| 94 | "\xC9" => 'É', |
| 95 | "\xCA" => 'Ê', |
| 96 | "\xCB" => 'Ë', |
| 97 | "\xCC" => 'Ì', |
| 98 | "\xCD" => 'Í', |
| 99 | "\xCE" => 'Î', |
| 100 | "\xCF" => 'Ï', |
| 101 | "\xD0" => 'Ð', |
| 102 | "\xD1" => 'Ñ', |
| 103 | "\xD2" => 'Ò', |
| 104 | "\xD3" => 'Ó', |
| 105 | "\xD4" => 'Ô', |
| 106 | "\xD5" => 'Õ', |
| 107 | "\xD6" => 'Ö', |
| 108 | "\xD7" => '×', |
| 109 | "\xD8" => 'Ø', |
| 110 | "\xD9" => 'Ù', |
| 111 | "\xDA" => 'Ú', |
| 112 | "\xDB" => 'Û', |
| 113 | "\xDC" => 'Ü', |
| 114 | "\xDD" => 'Ý', |
| 115 | "\xDE" => 'Þ', |
| 116 | "\xDF" => 'ß', |
| 117 | "\xE0" => 'à', |
| 118 | "\xE1" => 'á', |
| 119 | "\xE2" => 'â', |
| 120 | "\xE3" => 'ã', |
| 121 | "\xE4" => 'ä', |
| 122 | "\xE5" => 'å', |
| 123 | "\xE6" => 'æ', |
| 124 | "\xE7" => 'ç', |
| 125 | "\xE8" => 'è', |
| 126 | "\xE9" => 'é', |
| 127 | "\xEA" => 'ê', |
| 128 | "\xEB" => 'ë', |
| 129 | "\xEC" => 'ì', |
| 130 | "\xED" => 'í', |
| 131 | "\xEE" => 'î', |
| 132 | "\xEF" => 'ï', |
| 133 | "\xF0" => 'ð', |
| 134 | "\xF1" => 'ñ', |
| 135 | "\xF2" => 'ò', |
| 136 | "\xF3" => 'ó', |
| 137 | "\xF4" => 'ô', |
| 138 | "\xF5" => 'õ', |
| 139 | "\xF6" => 'ö', |
| 140 | "\xF7" => '÷', |
| 141 | "\xF8" => 'ø', |
| 142 | "\xF9" => 'ù', |
| 143 | "\xFA" => 'ú', |
| 144 | "\xFB" => 'û', |
| 145 | "\xFC" => 'ü', |
| 146 | "\xFD" => 'ý', |
| 147 | "\xFE" => 'þ', |
| 148 | "\xFF" => 'ÿ' |
| 149 | ); |
| 150 | |
| 151 | $string = str_replace(array_keys($iso8859_15), array_values($iso8859_15), $string); |
| 152 | |
| 153 | return $string; |
| 154 | } |
| 155 | |
| 156 | ?> |