d672fcab |
1 | <?php |
4b4abf93 |
2 | |
d6c32258 |
3 | /** |
d672fcab |
4 | * decode/iso8859-4.php |
d672fcab |
5 | * |
d672fcab |
6 | * This file contains iso-8859-4 decoding function that is needed to read |
7 | * iso-8859-4 encoded mails in non-iso-8859-4 locale. |
91e0dccc |
8 | * |
d672fcab |
9 | * Original data taken from: |
10 | * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-4.TXT |
11 | * |
12 | * Name: ISO/IEC 8859-4:1998 to Unicode |
13 | * Unicode version: 3.0 |
14 | * Table version: 1.0 |
15 | * Table format: Format A |
16 | * Date: 1999 July 27 |
17 | * Authors: Ken Whistler <kenw@sybase.com> |
18 | * |
19 | * Original copyright: |
e53c9681 |
20 | * Copyright (c) 1999 Unicode, Inc. All Rights reserved. |
d672fcab |
21 | * |
e53c9681 |
22 | * This file is provided as-is by Unicode, Inc. (The Unicode Consortium). |
23 | * No claims are made as to fitness for any particular purpose. No |
24 | * warranties of any kind are expressed or implied. The recipient |
25 | * agrees to determine applicability of information provided. If this |
26 | * file has been provided on optical media by Unicode, Inc., the sole |
27 | * remedy for any claim will be exchange of defective media within 90 |
28 | * days of receipt. |
d672fcab |
29 | * |
e53c9681 |
30 | * Unicode, Inc. hereby grants the right to freely use the information |
31 | * supplied in this file in the creation of products supporting the |
32 | * Unicode Standard, and to make copies of this file in any form for |
33 | * internal or external distribution as long as this notice remains |
34 | * attached. |
31841a9e |
35 | * |
47ccfad4 |
36 | * @copyright © 2003-2006 The SquirrelMail Project Team |
4b4abf93 |
37 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
31841a9e |
38 | * @version $Id$ |
d6c32258 |
39 | * @package squirrelmail |
40 | * @subpackage decode |
41 | */ |
42 | |
43 | /** |
44 | * Decode iso8859-4 string |
45 | * @param string $string Encoded string |
46 | * @return string $string Decoded string |
d672fcab |
47 | */ |
df8c4d6d |
48 | function charset_decode_iso_8859_4 ($string) { |
e53c9681 |
49 | // don't do decoding when there are no 8bit symbols |
50 | if (! sq_is8bit($string,'iso-8859-4')) |
d672fcab |
51 | return $string; |
52 | |
53 | $iso8859_4 = array( |
e53c9681 |
54 | "\xA0" => ' ', |
55 | "\xA1" => 'Ą', |
56 | "\xA2" => 'ĸ', |
57 | "\xA3" => 'Ŗ', |
58 | "\xA4" => '¤', |
59 | "\xA5" => 'Ĩ', |
60 | "\xA6" => 'Ļ', |
61 | "\xA7" => '§', |
62 | "\xA8" => '¨', |
63 | "\xA9" => 'Š', |
64 | "\xAA" => 'Ē', |
65 | "\xAB" => 'Ģ', |
66 | "\xAC" => 'Ŧ', |
67 | "\xAD" => '­', |
68 | "\xAE" => 'Ž', |
69 | "\xAF" => '¯', |
70 | "\xB0" => '°', |
71 | "\xB1" => 'ą', |
72 | "\xB2" => '˛', |
73 | "\xB3" => 'ŗ', |
74 | "\xB4" => '´', |
75 | "\xB5" => 'ĩ', |
76 | "\xB6" => 'ļ', |
77 | "\xB7" => 'ˇ', |
78 | "\xB8" => '¸', |
79 | "\xB9" => 'š', |
80 | "\xBA" => 'ē', |
81 | "\xBB" => 'ģ', |
82 | "\xBC" => 'ŧ', |
83 | "\xBD" => 'Ŋ', |
84 | "\xBE" => 'ž', |
85 | "\xBF" => 'ŋ', |
86 | "\xC0" => 'Ā', |
87 | "\xC1" => 'Á', |
88 | "\xC2" => 'Â', |
89 | "\xC3" => 'Ã', |
90 | "\xC4" => 'Ä', |
91 | "\xC5" => 'Å', |
92 | "\xC6" => 'Æ', |
93 | "\xC7" => 'Į', |
94 | "\xC8" => 'Č', |
95 | "\xC9" => 'É', |
96 | "\xCA" => 'Ę', |
97 | "\xCB" => 'Ë', |
98 | "\xCC" => 'Ė', |
99 | "\xCD" => 'Í', |
100 | "\xCE" => 'Î', |
101 | "\xCF" => 'Ī', |
102 | "\xD0" => 'Đ', |
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 | "\xE3" => 'ã', |
122 | "\xE4" => 'ä', |
123 | "\xE5" => 'å', |
124 | "\xE6" => 'æ', |
125 | "\xE7" => 'į', |
126 | "\xE8" => 'č', |
127 | "\xE9" => 'é', |
128 | "\xEA" => 'ę', |
129 | "\xEB" => 'ë', |
130 | "\xEC" => 'ė', |
131 | "\xED" => 'í', |
132 | "\xEE" => 'î', |
133 | "\xEF" => 'ī', |
134 | "\xF0" => 'đ', |
135 | "\xF1" => 'ņ', |
136 | "\xF2" => 'ō', |
137 | "\xF3" => 'ķ', |
138 | "\xF4" => 'ô', |
139 | "\xF5" => 'õ', |
140 | "\xF6" => 'ö', |
141 | "\xF7" => '÷', |
142 | "\xF8" => 'ø', |
143 | "\xF9" => 'ų', |
144 | "\xFA" => 'ú', |
145 | "\xFB" => 'û', |
146 | "\xFC" => 'ü', |
147 | "\xFD" => 'ũ', |
148 | "\xFE" => 'ū', |
149 | "\xFF" => '˙' |
d672fcab |
150 | ); |
151 | |
152 | $string = str_replace(array_keys($iso8859_4), array_values($iso8859_4), $string); |
153 | |
154 | return $string; |
155 | } |