removing default_charset tests. code can be reused in main function and
[squirrelmail.git] / functions / decode / iso_8859_15.php
1 <?php
2 /**
3 * decode/iso8859-15.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-15 decoding function that is needed to read
9 * iso-8859-15 encoded mails in non-iso-8859-15 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-15.TXT
13 *
14 * Name: ISO/IEC 8859-15: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: Markus Kuhn <mkuhn@acm.org>
20 * 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 * @version $Id$
40 * @package squirrelmail
41 * @subpackage decode
42 */
43
44 /**
45 * Decode iso8859-15 encoded string
46 * @param string $string Encoded string
47 * @return string $string Decoded string
48 */
49 function charset_decode_iso_8859_15 ($string) {
50 // don't do decoding when there are no 8bit symbols
51 if (! sq_is8bit($string,'iso-8859-15'))
52 return $string;
53
54 $iso8859_15 = array(
55 "\xA0" => '&#160;',
56 "\xA1" => '&#161;',
57 "\xA2" => '&#162;',
58 "\xA3" => '&#163;',
59 "\xA4" => '&#8364;',
60 "\xA5" => '&#165;',
61 "\xA6" => '&#352;',
62 "\xA7" => '&#167;',
63 "\xA8" => '&#353;',
64 "\xA9" => '&#169;',
65 "\xAA" => '&#170;',
66 "\xAB" => '&#171;',
67 "\xAC" => '&#172;',
68 "\xAD" => '&#173;',
69 "\xAE" => '&#174;',
70 "\xAF" => '&#175;',
71 "\xB0" => '&#176;',
72 "\xB1" => '&#177;',
73 "\xB2" => '&#178;',
74 "\xB3" => '&#179;',
75 "\xB4" => '&#381;',
76 "\xB5" => '&#181;',
77 "\xB6" => '&#182;',
78 "\xB7" => '&#183;',
79 "\xB8" => '&#382;',
80 "\xB9" => '&#185;',
81 "\xBA" => '&#186;',
82 "\xBB" => '&#187;',
83 "\xBC" => '&#338;',
84 "\xBD" => '&#339;',
85 "\xBE" => '&#376;',
86 "\xBF" => '&#191;',
87 "\xC0" => '&#192;',
88 "\xC1" => '&#193;',
89 "\xC2" => '&#194;',
90 "\xC3" => '&#195;',
91 "\xC4" => '&#196;',
92 "\xC5" => '&#197;',
93 "\xC6" => '&#198;',
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 "\xD0" => '&#208;',
104 "\xD1" => '&#209;',
105 "\xD2" => '&#210;',
106 "\xD3" => '&#211;',
107 "\xD4" => '&#212;',
108 "\xD5" => '&#213;',
109 "\xD6" => '&#214;',
110 "\xD7" => '&#215;',
111 "\xD8" => '&#216;',
112 "\xD9" => '&#217;',
113 "\xDA" => '&#218;',
114 "\xDB" => '&#219;',
115 "\xDC" => '&#220;',
116 "\xDD" => '&#221;',
117 "\xDE" => '&#222;',
118 "\xDF" => '&#223;',
119 "\xE0" => '&#224;',
120 "\xE1" => '&#225;',
121 "\xE2" => '&#226;',
122 "\xE3" => '&#227;',
123 "\xE4" => '&#228;',
124 "\xE5" => '&#229;',
125 "\xE6" => '&#230;',
126 "\xE7" => '&#231;',
127 "\xE8" => '&#232;',
128 "\xE9" => '&#233;',
129 "\xEA" => '&#234;',
130 "\xEB" => '&#235;',
131 "\xEC" => '&#236;',
132 "\xED" => '&#237;',
133 "\xEE" => '&#238;',
134 "\xEF" => '&#239;',
135 "\xF0" => '&#240;',
136 "\xF1" => '&#241;',
137 "\xF2" => '&#242;',
138 "\xF3" => '&#243;',
139 "\xF4" => '&#244;',
140 "\xF5" => '&#245;',
141 "\xF6" => '&#246;',
142 "\xF7" => '&#247;',
143 "\xF8" => '&#248;',
144 "\xF9" => '&#249;',
145 "\xFA" => '&#250;',
146 "\xFB" => '&#251;',
147 "\xFC" => '&#252;',
148 "\xFD" => '&#253;',
149 "\xFE" => '&#254;',
150 "\xFF" => '&#255;'
151 );
152
153 $string = str_replace(array_keys($iso8859_15), array_values($iso8859_15), $string);
154
155 return $string;
156 }
157 ?>