Makes managing decoding easier. Mac decoding moved to separate cvs module
[squirrelmail.git] / functions / decode / iso_8859_15.php
1 <?php
2 /**
3 * decode/iso8859-15.php
4 * $Id$
5 *
6 * Copyright (c) 2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file contains iso-8859-15 decoding function that is needed to read
10 * iso-8859-15 encoded mails in non-iso-8859-15 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-15.TXT
14 *
15 * Name: ISO/IEC 8859-15: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: Markus Kuhn <mkuhn@acm.org>
21 * Ken Whistler <kenw@sybase.com>
22 *
23 * Original copyright:
24 * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
25 *
26 * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
27 * No claims are made as to fitness for any particular purpose. No
28 * warranties of any kind are expressed or implied. The recipient
29 * agrees to determine applicability of information provided. If this
30 * file has been provided on optical media by Unicode, Inc., the sole
31 * remedy for any claim will be exchange of defective media within 90
32 * days of receipt.
33 *
34 * Unicode, Inc. hereby grants the right to freely use the information
35 * supplied in this file in the creation of products supporting the
36 * Unicode Standard, and to make copies of this file in any form for
37 * internal or external distribution as long as this notice remains
38 * attached.
39 * @package squirrelmail
40 * @subpackage decode
41 */
42
43 /**
44 * Decode iso8859-15 encoded string
45 * @param string $string Encoded string
46 * @return string $string Decoded string
47 */
48 function charset_decode_iso_8859_15 ($string) {
49 global $default_charset;
50
51 if (strtolower($default_charset) == 'iso-8859-15')
52 return $string;
53
54 /* Only do the slow convert if there are 8-bit characters */
55 /* there is no 0x80-0x9F letters in ISO8859-* */
56 if ( ! ereg("[\241-\377]", $string) )
57 return $string;
58
59 $iso8859_15 = array(
60 "\xA0" => '&#160;',
61 "\xA1" => '&#161;',
62 "\xA2" => '&#162;',
63 "\xA3" => '&#163;',
64 "\xA4" => '&#8364;',
65 "\xA5" => '&#165;',
66 "\xA6" => '&#352;',
67 "\xA7" => '&#167;',
68 "\xA8" => '&#353;',
69 "\xA9" => '&#169;',
70 "\xAA" => '&#170;',
71 "\xAB" => '&#171;',
72 "\xAC" => '&#172;',
73 "\xAD" => '&#173;',
74 "\xAE" => '&#174;',
75 "\xAF" => '&#175;',
76 "\xB0" => '&#176;',
77 "\xB1" => '&#177;',
78 "\xB2" => '&#178;',
79 "\xB3" => '&#179;',
80 "\xB4" => '&#381;',
81 "\xB5" => '&#181;',
82 "\xB6" => '&#182;',
83 "\xB7" => '&#183;',
84 "\xB8" => '&#382;',
85 "\xB9" => '&#185;',
86 "\xBA" => '&#186;',
87 "\xBB" => '&#187;',
88 "\xBC" => '&#338;',
89 "\xBD" => '&#339;',
90 "\xBE" => '&#376;',
91 "\xBF" => '&#191;',
92 "\xC0" => '&#192;',
93 "\xC1" => '&#193;',
94 "\xC2" => '&#194;',
95 "\xC3" => '&#195;',
96 "\xC4" => '&#196;',
97 "\xC5" => '&#197;',
98 "\xC6" => '&#198;',
99 "\xC7" => '&#199;',
100 "\xC8" => '&#200;',
101 "\xC9" => '&#201;',
102 "\xCA" => '&#202;',
103 "\xCB" => '&#203;',
104 "\xCC" => '&#204;',
105 "\xCD" => '&#205;',
106 "\xCE" => '&#206;',
107 "\xCF" => '&#207;',
108 "\xD0" => '&#208;',
109 "\xD1" => '&#209;',
110 "\xD2" => '&#210;',
111 "\xD3" => '&#211;',
112 "\xD4" => '&#212;',
113 "\xD5" => '&#213;',
114 "\xD6" => '&#214;',
115 "\xD7" => '&#215;',
116 "\xD8" => '&#216;',
117 "\xD9" => '&#217;',
118 "\xDA" => '&#218;',
119 "\xDB" => '&#219;',
120 "\xDC" => '&#220;',
121 "\xDD" => '&#221;',
122 "\xDE" => '&#222;',
123 "\xDF" => '&#223;',
124 "\xE0" => '&#224;',
125 "\xE1" => '&#225;',
126 "\xE2" => '&#226;',
127 "\xE3" => '&#227;',
128 "\xE4" => '&#228;',
129 "\xE5" => '&#229;',
130 "\xE6" => '&#230;',
131 "\xE7" => '&#231;',
132 "\xE8" => '&#232;',
133 "\xE9" => '&#233;',
134 "\xEA" => '&#234;',
135 "\xEB" => '&#235;',
136 "\xEC" => '&#236;',
137 "\xED" => '&#237;',
138 "\xEE" => '&#238;',
139 "\xEF" => '&#239;',
140 "\xF0" => '&#240;',
141 "\xF1" => '&#241;',
142 "\xF2" => '&#242;',
143 "\xF3" => '&#243;',
144 "\xF4" => '&#244;',
145 "\xF5" => '&#245;',
146 "\xF6" => '&#246;',
147 "\xF7" => '&#247;',
148 "\xF8" => '&#248;',
149 "\xF9" => '&#249;',
150 "\xFA" => '&#250;',
151 "\xFB" => '&#251;',
152 "\xFC" => '&#252;',
153 "\xFD" => '&#253;',
154 "\xFE" => '&#254;',
155 "\xFF" => '&#255;'
156 );
157
158 $string = str_replace(array_keys($iso8859_15), array_values($iso8859_15), $string);
159
160 return $string;
161 }
162
163 ?>