b28cee66d6834853486e1be7d9565a8cf58eda24
[squirrelmail.git] / functions / decode / iso_8859_3.php
1 <?php
2 /**
3 * decode/iso8859-3.php
4 *
5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This file contains iso-8859-3 decoding function that is needed to read
9 * iso-8859-3 encoded mails in non-iso-8859-3 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-3.TXT
13 *
14 * Name: ISO/IEC 8859-3:1999 to Unicode
15 * Unicode version: 3.0
16 * Table version: 1.0
17 * Table format: Format A
18 * Date: 1999 July 27
19 * Authors: Ken Whistler <kenw@sybase.com>
20 *
21 * Original copyright:
22 * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
23 *
24 * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
25 * No claims are made as to fitness for any particular purpose. No
26 * warranties of any kind are expressed or implied. The recipient
27 * agrees to determine applicability of information provided. If this
28 * file has been provided on optical media by Unicode, Inc., the sole
29 * remedy for any claim will be exchange of defective media within 90
30 * days of receipt.
31 *
32 * Unicode, Inc. hereby grants the right to freely use the information
33 * supplied in this file in the creation of products supporting the
34 * Unicode Standard, and to make copies of this file in any form for
35 * internal or external distribution as long as this notice remains
36 * attached.
37 *
38 * @version $Id$
39 * @package squirrelmail
40 * @subpackage decode
41 */
42
43 /**
44 * Decode iso8859-3 encoded string
45 * @param string $string Encoded string
46 * @return string $string Decoded string
47 */
48 function charset_decode_iso_8859_3 ($string) {
49 global $default_charset;
50
51 if (strtolower($default_charset) == 'iso-8859-3')
52 return $string;
53
54 // don't do decoding when there are no 8bit symbols
55 if (! sq_is8bit($string,'iso-8859-3'))
56 return $string;
57
58 $iso8859_3 = array(
59 "\xA0" => '&#160;',
60 "\xA1" => '&#294;',
61 "\xA2" => '&#728;',
62 "\xA3" => '&#163;',
63 "\xA4" => '&#164;',
64 "\xA6" => '&#292;',
65 "\xA7" => '&#167;',
66 "\xA8" => '&#168;',
67 "\xA9" => '&#304;',
68 "\xAA" => '&#350;',
69 "\xAB" => '&#286;',
70 "\xAC" => '&#308;',
71 "\xAD" => '&#173;',
72 "\xAF" => '&#379;',
73 "\xB0" => '&#176;',
74 "\xB1" => '&#295;',
75 "\xB2" => '&#178;',
76 "\xB3" => '&#179;',
77 "\xB4" => '&#180;',
78 "\xB5" => '&#181;',
79 "\xB6" => '&#293;',
80 "\xB7" => '&#183;',
81 "\xB8" => '&#184;',
82 "\xB9" => '&#305;',
83 "\xBA" => '&#351;',
84 "\xBB" => '&#287;',
85 "\xBC" => '&#309;',
86 "\xBD" => '&#189;',
87 "\xBF" => '&#380;',
88 "\xC0" => '&#192;',
89 "\xC1" => '&#193;',
90 "\xC2" => '&#194;',
91 "\xC4" => '&#196;',
92 "\xC5" => '&#266;',
93 "\xC6" => '&#264;',
94 "\xC7" => '&#199;',
95 "\xC8" => '&#200;',
96 "\xC9" => '&#201;',
97 "\xCA" => '&#202;',
98 "\xCB" => '&#203;',
99 "\xCC" => '&#204;',
100 "\xCD" => '&#205;',
101 "\xCE" => '&#206;',
102 "\xCF" => '&#207;',
103 "\xD1" => '&#209;',
104 "\xD2" => '&#210;',
105 "\xD3" => '&#211;',
106 "\xD4" => '&#212;',
107 "\xD5" => '&#288;',
108 "\xD6" => '&#214;',
109 "\xD7" => '&#215;',
110 "\xD8" => '&#284;',
111 "\xD9" => '&#217;',
112 "\xDA" => '&#218;',
113 "\xDB" => '&#219;',
114 "\xDC" => '&#220;',
115 "\xDD" => '&#364;',
116 "\xDE" => '&#348;',
117 "\xDF" => '&#223;',
118 "\xE0" => '&#224;',
119 "\xE1" => '&#225;',
120 "\xE2" => '&#226;',
121 "\xE4" => '&#228;',
122 "\xE5" => '&#267;',
123 "\xE6" => '&#265;',
124 "\xE7" => '&#231;',
125 "\xE8" => '&#232;',
126 "\xE9" => '&#233;',
127 "\xEA" => '&#234;',
128 "\xEB" => '&#235;',
129 "\xEC" => '&#236;',
130 "\xED" => '&#237;',
131 "\xEE" => '&#238;',
132 "\xEF" => '&#239;',
133 "\xF1" => '&#241;',
134 "\xF2" => '&#242;',
135 "\xF3" => '&#243;',
136 "\xF4" => '&#244;',
137 "\xF5" => '&#289;',
138 "\xF6" => '&#246;',
139 "\xF7" => '&#247;',
140 "\xF8" => '&#285;',
141 "\xF9" => '&#249;',
142 "\xFA" => '&#250;',
143 "\xFB" => '&#251;',
144 "\xFC" => '&#252;',
145 "\xFD" => '&#365;',
146 "\xFE" => '&#349;',
147 "\xFF" => '&#729;'
148 );
149
150 $string = str_replace(array_keys($iso8859_3), array_values($iso8859_3), $string);
151
152 return $string;
153 }
154 ?>