3cf011a61fdaed65a72947295cb9318f41e009c8
[squirrelmail.git] / functions / decode / iso_8859_3.php
1 <?php
2
3 /**
4 * decode/iso8859-3.php
5 *
6 * This file contains iso-8859-3 decoding function that is needed to read
7 * iso-8859-3 encoded mails in non-iso-8859-3 locale.
8 *
9 * Original data taken from:
10 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-3.TXT
11 *
12 * Name: ISO/IEC 8859-3:1999 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:
20 * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
21 *
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.
29 *
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.
35 *
36 * @copyright 2003-2011 The SquirrelMail Project Team
37 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
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 // don't do decoding when there are no 8bit symbols
50 if (! sq_is8bit($string,'iso-8859-3'))
51 return $string;
52
53 $iso8859_3 = array(
54 "\xA0" => '&#160;',
55 "\xA1" => '&#294;',
56 "\xA2" => '&#728;',
57 "\xA3" => '&#163;',
58 "\xA4" => '&#164;',
59 "\xA6" => '&#292;',
60 "\xA7" => '&#167;',
61 "\xA8" => '&#168;',
62 "\xA9" => '&#304;',
63 "\xAA" => '&#350;',
64 "\xAB" => '&#286;',
65 "\xAC" => '&#308;',
66 "\xAD" => '&#173;',
67 "\xAF" => '&#379;',
68 "\xB0" => '&#176;',
69 "\xB1" => '&#295;',
70 "\xB2" => '&#178;',
71 "\xB3" => '&#179;',
72 "\xB4" => '&#180;',
73 "\xB5" => '&#181;',
74 "\xB6" => '&#293;',
75 "\xB7" => '&#183;',
76 "\xB8" => '&#184;',
77 "\xB9" => '&#305;',
78 "\xBA" => '&#351;',
79 "\xBB" => '&#287;',
80 "\xBC" => '&#309;',
81 "\xBD" => '&#189;',
82 "\xBF" => '&#380;',
83 "\xC0" => '&#192;',
84 "\xC1" => '&#193;',
85 "\xC2" => '&#194;',
86 "\xC4" => '&#196;',
87 "\xC5" => '&#266;',
88 "\xC6" => '&#264;',
89 "\xC7" => '&#199;',
90 "\xC8" => '&#200;',
91 "\xC9" => '&#201;',
92 "\xCA" => '&#202;',
93 "\xCB" => '&#203;',
94 "\xCC" => '&#204;',
95 "\xCD" => '&#205;',
96 "\xCE" => '&#206;',
97 "\xCF" => '&#207;',
98 "\xD1" => '&#209;',
99 "\xD2" => '&#210;',
100 "\xD3" => '&#211;',
101 "\xD4" => '&#212;',
102 "\xD5" => '&#288;',
103 "\xD6" => '&#214;',
104 "\xD7" => '&#215;',
105 "\xD8" => '&#284;',
106 "\xD9" => '&#217;',
107 "\xDA" => '&#218;',
108 "\xDB" => '&#219;',
109 "\xDC" => '&#220;',
110 "\xDD" => '&#364;',
111 "\xDE" => '&#348;',
112 "\xDF" => '&#223;',
113 "\xE0" => '&#224;',
114 "\xE1" => '&#225;',
115 "\xE2" => '&#226;',
116 "\xE4" => '&#228;',
117 "\xE5" => '&#267;',
118 "\xE6" => '&#265;',
119 "\xE7" => '&#231;',
120 "\xE8" => '&#232;',
121 "\xE9" => '&#233;',
122 "\xEA" => '&#234;',
123 "\xEB" => '&#235;',
124 "\xEC" => '&#236;',
125 "\xED" => '&#237;',
126 "\xEE" => '&#238;',
127 "\xEF" => '&#239;',
128 "\xF1" => '&#241;',
129 "\xF2" => '&#242;',
130 "\xF3" => '&#243;',
131 "\xF4" => '&#244;',
132 "\xF5" => '&#289;',
133 "\xF6" => '&#246;',
134 "\xF7" => '&#247;',
135 "\xF8" => '&#285;',
136 "\xF9" => '&#249;',
137 "\xFA" => '&#250;',
138 "\xFB" => '&#251;',
139 "\xFC" => '&#252;',
140 "\xFD" => '&#365;',
141 "\xFE" => '&#349;',
142 "\xFF" => '&#729;'
143 );
144
145 $string = str_replace(array_keys($iso8859_3), array_values($iso8859_3), $string);
146
147 return $string;
148 }