Fixed dates in copyright. added koi8-r and koi8-u decoding. fixed ereg in
[squirrelmail.git] / functions / decode / iso8859-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 *
40 */
41 function charset_decode_iso8859_15 ($string) {
42 global $default_charset;
43
44 if (strtolower($default_charset) == 'iso-8859-15')
45 return $string;
46
47 /* Only do the slow convert if there are 8-bit characters */
48 /* there is no 0x80-0x9F letters in ISO8859-* */
49 if ( ! ereg("[\241-\377]", $string) )
50 return $string;
51
52 $iso8859_15 = array(
53 "\xA0" => '&#160;',
54 "\xA1" => '&#161;',
55 "\xA2" => '&#162;',
56 "\xA3" => '&#163;',
57 "\xA4" => '&#8364;',
58 "\xA5" => '&#165;',
59 "\xA6" => '&#352;',
60 "\xA7" => '&#167;',
61 "\xA8" => '&#353;',
62 "\xA9" => '&#169;',
63 "\xAA" => '&#170;',
64 "\xAB" => '&#171;',
65 "\xAC" => '&#172;',
66 "\xAD" => '&#173;',
67 "\xAE" => '&#174;',
68 "\xAF" => '&#175;',
69 "\xB0" => '&#176;',
70 "\xB1" => '&#177;',
71 "\xB2" => '&#178;',
72 "\xB3" => '&#179;',
73 "\xB4" => '&#381;',
74 "\xB5" => '&#181;',
75 "\xB6" => '&#182;',
76 "\xB7" => '&#183;',
77 "\xB8" => '&#382;',
78 "\xB9" => '&#185;',
79 "\xBA" => '&#186;',
80 "\xBB" => '&#187;',
81 "\xBC" => '&#338;',
82 "\xBD" => '&#339;',
83 "\xBE" => '&#376;',
84 "\xBF" => '&#191;',
85 "\xC0" => '&#192;',
86 "\xC1" => '&#193;',
87 "\xC2" => '&#194;',
88 "\xC3" => '&#195;',
89 "\xC4" => '&#196;',
90 "\xC5" => '&#197;',
91 "\xC6" => '&#198;',
92 "\xC7" => '&#199;',
93 "\xC8" => '&#200;',
94 "\xC9" => '&#201;',
95 "\xCA" => '&#202;',
96 "\xCB" => '&#203;',
97 "\xCC" => '&#204;',
98 "\xCD" => '&#205;',
99 "\xCE" => '&#206;',
100 "\xCF" => '&#207;',
101 "\xD0" => '&#208;',
102 "\xD1" => '&#209;',
103 "\xD2" => '&#210;',
104 "\xD3" => '&#211;',
105 "\xD4" => '&#212;',
106 "\xD5" => '&#213;',
107 "\xD6" => '&#214;',
108 "\xD7" => '&#215;',
109 "\xD8" => '&#216;',
110 "\xD9" => '&#217;',
111 "\xDA" => '&#218;',
112 "\xDB" => '&#219;',
113 "\xDC" => '&#220;',
114 "\xDD" => '&#221;',
115 "\xDE" => '&#222;',
116 "\xDF" => '&#223;',
117 "\xE0" => '&#224;',
118 "\xE1" => '&#225;',
119 "\xE2" => '&#226;',
120 "\xE3" => '&#227;',
121 "\xE4" => '&#228;',
122 "\xE5" => '&#229;',
123 "\xE6" => '&#230;',
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 "\xF0" => '&#240;',
134 "\xF1" => '&#241;',
135 "\xF2" => '&#242;',
136 "\xF3" => '&#243;',
137 "\xF4" => '&#244;',
138 "\xF5" => '&#245;',
139 "\xF6" => '&#246;',
140 "\xF7" => '&#247;',
141 "\xF8" => '&#248;',
142 "\xF9" => '&#249;',
143 "\xFA" => '&#250;',
144 "\xFB" => '&#251;',
145 "\xFC" => '&#252;',
146 "\xFD" => '&#253;',
147 "\xFE" => '&#254;',
148 "\xFF" => '&#255;'
149 );
150
151 $string = str_replace(array_keys($iso8859_15), array_values($iso8859_15), $string);
152
153 return $string;
154 }
155
156 ?>