d672fcab |
1 | <?php |
2 | /* |
3 | * decode/iso8859-5.php |
4 | * $Id$ |
5 | * |
0a708025 |
6 | * Copyright (c) 2003 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-5 decoding function that is needed to read |
10 | * iso-8859-5 encoded mails in non-iso-8859-5 locale. |
11 | * |
12 | * Original data taken from: |
13 | * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-5.TXT |
14 | * |
15 | * Name: ISO 8859-5: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_5 ($string) { |
41 | global $default_charset; |
42 | |
43 | if (strtolower($default_charset) == 'iso-8859-5') |
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_5 = array( |
52 | "\xA0" => ' ', |
53 | "\xA1" => 'Ё', |
54 | "\xA2" => 'Ђ', |
55 | "\xA3" => 'Ѓ', |
56 | "\xA4" => 'Є', |
57 | "\xA5" => 'Ѕ', |
58 | "\xA6" => 'І', |
59 | "\xA7" => 'Ї', |
60 | "\xA8" => 'Ј', |
61 | "\xA9" => 'Љ', |
62 | "\xAA" => 'Њ', |
63 | "\xAB" => 'Ћ', |
64 | "\xAC" => 'Ќ', |
65 | "\xAD" => '­', |
66 | "\xAE" => 'Ў', |
67 | "\xAF" => 'Џ', |
68 | "\xB0" => 'А', |
69 | "\xB1" => 'Б', |
70 | "\xB2" => 'В', |
71 | "\xB3" => 'Г', |
72 | "\xB4" => 'Д', |
73 | "\xB5" => 'Е', |
74 | "\xB6" => 'Ж', |
75 | "\xB7" => 'З', |
76 | "\xB8" => 'И', |
77 | "\xB9" => 'Й', |
78 | "\xBA" => 'К', |
79 | "\xBB" => 'Л', |
80 | "\xBC" => 'М', |
81 | "\xBD" => 'Н', |
82 | "\xBE" => 'О', |
83 | "\xBF" => 'П', |
84 | "\xC0" => 'Р', |
85 | "\xC1" => 'С', |
86 | "\xC2" => 'Т', |
87 | "\xC3" => 'У', |
88 | "\xC4" => 'Ф', |
89 | "\xC5" => 'Х', |
90 | "\xC6" => 'Ц', |
91 | "\xC7" => 'Ч', |
92 | "\xC8" => 'Ш', |
93 | "\xC9" => 'Щ', |
94 | "\xCA" => 'Ъ', |
95 | "\xCB" => 'Ы', |
96 | "\xCC" => 'Ь', |
97 | "\xCD" => 'Э', |
98 | "\xCE" => 'Ю', |
99 | "\xCF" => 'Я', |
100 | "\xD0" => 'а', |
101 | "\xD1" => 'б', |
102 | "\xD2" => 'в', |
103 | "\xD3" => 'г', |
104 | "\xD4" => 'д', |
105 | "\xD5" => 'е', |
106 | "\xD6" => 'ж', |
107 | "\xD7" => 'з', |
108 | "\xD8" => 'и', |
109 | "\xD9" => 'й', |
110 | "\xDA" => 'к', |
111 | "\xDB" => 'л', |
112 | "\xDC" => 'м', |
113 | "\xDD" => 'н', |
114 | "\xDE" => 'о', |
115 | "\xDF" => 'п', |
116 | "\xE0" => 'р', |
117 | "\xE1" => 'с', |
118 | "\xE2" => 'т', |
119 | "\xE3" => 'у', |
120 | "\xE4" => 'ф', |
121 | "\xE5" => 'х', |
122 | "\xE6" => 'ц', |
123 | "\xE7" => 'ч', |
124 | "\xE8" => 'ш', |
125 | "\xE9" => 'щ', |
126 | "\xEA" => 'ъ', |
127 | "\xEB" => 'ы', |
128 | "\xEC" => 'ь', |
129 | "\xED" => 'э', |
130 | "\xEE" => 'ю', |
131 | "\xEF" => 'я', |
132 | "\xF0" => '№', |
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_5), array_values($iso8859_5), $string); |
151 | |
152 | return $string; |
153 | } |
154 | |
155 | ?> |