d672fcab |
1 | <?php |
d6c32258 |
2 | /** |
d672fcab |
3 | * decode/iso8859-3.php |
4 | * $Id$ |
5 | * |
82d304a0 |
6 | * Copyright (c) 2003-2004 The SquirrelMail Project Team |
d672fcab |
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. |
d6c32258 |
38 | * @package squirrelmail |
39 | * @subpackage decode |
40 | */ |
41 | |
42 | /** |
43 | * Decode iso8859-3 encoded string |
44 | * @param string $string Encoded string |
45 | * @return string $string Decoded string |
d672fcab |
46 | */ |
df8c4d6d |
47 | function charset_decode_iso_8859_3 ($string) { |
d672fcab |
48 | global $default_charset; |
49 | |
50 | if (strtolower($default_charset) == 'iso-8859-3') |
51 | return $string; |
52 | |
53 | /* Only do the slow convert if there are 8-bit characters */ |
54 | /* there is no 0x80-0x9F letters in ISO8859-* */ |
55 | if ( ! ereg("[\241-\377]", $string) ) |
56 | return $string; |
57 | |
58 | $iso8859_3 = array( |
59 | "\xA0" => ' ', |
60 | "\xA1" => 'Ħ', |
61 | "\xA2" => '˘', |
62 | "\xA3" => '£', |
63 | "\xA4" => '¤', |
64 | "\xA6" => 'Ĥ', |
65 | "\xA7" => '§', |
66 | "\xA8" => '¨', |
67 | "\xA9" => 'İ', |
68 | "\xAA" => 'Ş', |
69 | "\xAB" => 'Ğ', |
70 | "\xAC" => 'Ĵ', |
71 | "\xAD" => '­', |
72 | "\xAF" => 'Ż', |
73 | "\xB0" => '°', |
74 | "\xB1" => 'ħ', |
75 | "\xB2" => '²', |
76 | "\xB3" => '³', |
77 | "\xB4" => '´', |
78 | "\xB5" => 'µ', |
79 | "\xB6" => 'ĥ', |
80 | "\xB7" => '·', |
81 | "\xB8" => '¸', |
82 | "\xB9" => 'ı', |
83 | "\xBA" => 'ş', |
84 | "\xBB" => 'ğ', |
85 | "\xBC" => 'ĵ', |
86 | "\xBD" => '½', |
87 | "\xBF" => 'ż', |
88 | "\xC0" => 'À', |
89 | "\xC1" => 'Á', |
90 | "\xC2" => 'Â', |
91 | "\xC4" => 'Ä', |
92 | "\xC5" => 'Ċ', |
93 | "\xC6" => 'Ĉ', |
94 | "\xC7" => 'Ç', |
95 | "\xC8" => 'È', |
96 | "\xC9" => 'É', |
97 | "\xCA" => 'Ê', |
98 | "\xCB" => 'Ë', |
99 | "\xCC" => 'Ì', |
100 | "\xCD" => 'Í', |
101 | "\xCE" => 'Î', |
102 | "\xCF" => 'Ï', |
103 | "\xD1" => 'Ñ', |
104 | "\xD2" => 'Ò', |
105 | "\xD3" => 'Ó', |
106 | "\xD4" => 'Ô', |
107 | "\xD5" => 'Ġ', |
108 | "\xD6" => 'Ö', |
109 | "\xD7" => '×', |
110 | "\xD8" => 'Ĝ', |
111 | "\xD9" => 'Ù', |
112 | "\xDA" => 'Ú', |
113 | "\xDB" => 'Û', |
114 | "\xDC" => 'Ü', |
115 | "\xDD" => 'Ŭ', |
116 | "\xDE" => 'Ŝ', |
117 | "\xDF" => 'ß', |
118 | "\xE0" => 'à', |
119 | "\xE1" => 'á', |
120 | "\xE2" => 'â', |
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 | "\xF1" => 'ñ', |
134 | "\xF2" => 'ò', |
135 | "\xF3" => 'ó', |
136 | "\xF4" => 'ô', |
137 | "\xF5" => 'ġ', |
138 | "\xF6" => 'ö', |
139 | "\xF7" => '÷', |
140 | "\xF8" => 'ĝ', |
141 | "\xF9" => 'ù', |
142 | "\xFA" => 'ú', |
143 | "\xFB" => 'û', |
144 | "\xFC" => 'ü', |
145 | "\xFD" => 'ŭ', |
146 | "\xFE" => 'ŝ', |
147 | "\xFF" => '˙' |
148 | ); |
149 | |
150 | $string = str_replace(array_keys($iso8859_3), array_values($iso8859_3), $string); |
151 | |
152 | return $string; |
153 | } |
154 | |
d6c32258 |
155 | ?> |