| 1 | <?php |
| 2 | /* |
| 3 | * decode/iso8859-3.php |
| 4 | * $Id$ |
| 5 | * |
| 6 | * Copyright (c) 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-3 decoding function that is needed to read |
| 10 | * iso-8859-3 encoded mails in non-iso-8859-3 locale. |
| 11 | * |
| 12 | * Original data taken from: |
| 13 | * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-3.TXT |
| 14 | * |
| 15 | * Name: ISO/IEC 8859-3: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: Ken Whistler <kenw@sybase.com> |
| 21 | * |
| 22 | * Original copyright: |
| 23 | * Copyright (c) 1999 Unicode, Inc. All Rights reserved. |
| 24 | * |
| 25 | * This file is provided as-is by Unicode, Inc. (The Unicode Consortium). |
| 26 | * No claims are made as to fitness for any particular purpose. No |
| 27 | * warranties of any kind are expressed or implied. The recipient |
| 28 | * agrees to determine applicability of information provided. If this |
| 29 | * file has been provided on optical media by Unicode, Inc., the sole |
| 30 | * remedy for any claim will be exchange of defective media within 90 |
| 31 | * days of receipt. |
| 32 | * |
| 33 | * Unicode, Inc. hereby grants the right to freely use the information |
| 34 | * supplied in this file in the creation of products supporting the |
| 35 | * Unicode Standard, and to make copies of this file in any form for |
| 36 | * internal or external distribution as long as this notice remains |
| 37 | * attached. |
| 38 | * |
| 39 | */ |
| 40 | function charset_decode_iso8859_3 ($string) { |
| 41 | global $default_charset; |
| 42 | |
| 43 | if (strtolower($default_charset) == 'iso-8859-3') |
| 44 | return $string; |
| 45 | |
| 46 | /* Only do the slow convert if there are 8-bit characters */ |
| 47 | /* there is no 0x80-0x9F letters in ISO8859-* */ |
| 48 | if ( ! ereg("[\241-\377]", $string) ) |
| 49 | return $string; |
| 50 | |
| 51 | $iso8859_3 = array( |
| 52 | "\xA0" => ' ', |
| 53 | "\xA1" => 'Ħ', |
| 54 | "\xA2" => '˘', |
| 55 | "\xA3" => '£', |
| 56 | "\xA4" => '¤', |
| 57 | "\xA6" => 'Ĥ', |
| 58 | "\xA7" => '§', |
| 59 | "\xA8" => '¨', |
| 60 | "\xA9" => 'İ', |
| 61 | "\xAA" => 'Ş', |
| 62 | "\xAB" => 'Ğ', |
| 63 | "\xAC" => 'Ĵ', |
| 64 | "\xAD" => '­', |
| 65 | "\xAF" => 'Ż', |
| 66 | "\xB0" => '°', |
| 67 | "\xB1" => 'ħ', |
| 68 | "\xB2" => '²', |
| 69 | "\xB3" => '³', |
| 70 | "\xB4" => '´', |
| 71 | "\xB5" => 'µ', |
| 72 | "\xB6" => 'ĥ', |
| 73 | "\xB7" => '·', |
| 74 | "\xB8" => '¸', |
| 75 | "\xB9" => 'ı', |
| 76 | "\xBA" => 'ş', |
| 77 | "\xBB" => 'ğ', |
| 78 | "\xBC" => 'ĵ', |
| 79 | "\xBD" => '½', |
| 80 | "\xBF" => 'ż', |
| 81 | "\xC0" => 'À', |
| 82 | "\xC1" => 'Á', |
| 83 | "\xC2" => 'Â', |
| 84 | "\xC4" => 'Ä', |
| 85 | "\xC5" => 'Ċ', |
| 86 | "\xC6" => 'Ĉ', |
| 87 | "\xC7" => 'Ç', |
| 88 | "\xC8" => 'È', |
| 89 | "\xC9" => 'É', |
| 90 | "\xCA" => 'Ê', |
| 91 | "\xCB" => 'Ë', |
| 92 | "\xCC" => 'Ì', |
| 93 | "\xCD" => 'Í', |
| 94 | "\xCE" => 'Î', |
| 95 | "\xCF" => 'Ï', |
| 96 | "\xD1" => 'Ñ', |
| 97 | "\xD2" => 'Ò', |
| 98 | "\xD3" => 'Ó', |
| 99 | "\xD4" => 'Ô', |
| 100 | "\xD5" => 'Ġ', |
| 101 | "\xD6" => 'Ö', |
| 102 | "\xD7" => '×', |
| 103 | "\xD8" => 'Ĝ', |
| 104 | "\xD9" => 'Ù', |
| 105 | "\xDA" => 'Ú', |
| 106 | "\xDB" => 'Û', |
| 107 | "\xDC" => 'Ü', |
| 108 | "\xDD" => 'Ŭ', |
| 109 | "\xDE" => 'Ŝ', |
| 110 | "\xDF" => 'ß', |
| 111 | "\xE0" => 'à', |
| 112 | "\xE1" => 'á', |
| 113 | "\xE2" => 'â', |
| 114 | "\xE4" => 'ä', |
| 115 | "\xE5" => 'ċ', |
| 116 | "\xE6" => 'ĉ', |
| 117 | "\xE7" => 'ç', |
| 118 | "\xE8" => 'è', |
| 119 | "\xE9" => 'é', |
| 120 | "\xEA" => 'ê', |
| 121 | "\xEB" => 'ë', |
| 122 | "\xEC" => 'ì', |
| 123 | "\xED" => 'í', |
| 124 | "\xEE" => 'î', |
| 125 | "\xEF" => 'ï', |
| 126 | "\xF1" => 'ñ', |
| 127 | "\xF2" => 'ò', |
| 128 | "\xF3" => 'ó', |
| 129 | "\xF4" => 'ô', |
| 130 | "\xF5" => 'ġ', |
| 131 | "\xF6" => 'ö', |
| 132 | "\xF7" => '÷', |
| 133 | "\xF8" => 'ĝ', |
| 134 | "\xF9" => 'ù', |
| 135 | "\xFA" => 'ú', |
| 136 | "\xFB" => 'û', |
| 137 | "\xFC" => 'ü', |
| 138 | "\xFD" => 'ŭ', |
| 139 | "\xFE" => 'ŝ', |
| 140 | "\xFF" => '˙' |
| 141 | ); |
| 142 | |
| 143 | $string = str_replace(array_keys($iso8859_3), array_values($iso8859_3), $string); |
| 144 | |
| 145 | return $string; |
| 146 | } |
| 147 | |
| 148 | ?> |