c4194bb0950737d2ac5faa3bd91e713e0cba1822
[squirrelmail.git] / functions / decode / iso8859-16.php
1 <?php
2 /*
3 * decode/iso8859-16.php
4 * $Id$
5 *
6 * Copyright (c) 1999-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-16 decoding function that is needed to read
10 * iso-8859-16 encoded mails in non-iso-8859-16 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-16.TXT
14 *
15 * Name: ISO/IEC 8859-16:2001 to Unicode
16 * Unicode version: 3.0
17 * Table version: 1.0
18 * Table format: Format A
19 * Date: 2001 July 26
20 * Authors: Markus Kuhn <mkuhn@acm.org>
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 */
40 function charset_decode_iso8859_16 ($string) {
41 global $default_charset;
42
43 if (strtolower($default_charset) == 'iso-8859-16')
44 return $string;
45
46 /* Only do the slow convert if there are 8-bit characters */
47 /* there is no 0x80-0x9F letters in ISO8859-* */
48 if ( ! ereg("[\241-\377]", $string) )
49 return $string;
50
51 $iso8869_16 = array(
52 "\xA0" => '&#160;',
53 "\xA1" => '&#260;',
54 "\xA2" => '&#261;',
55 "\xA3" => '&#321;',
56 "\xA4" => '&#8364;',
57 "\xA5" => '&#8222;',
58 "\xA6" => '&#352;',
59 "\xA7" => '&#167;',
60 "\xA8" => '&#353;',
61 "\xA9" => '&#169;',
62 "\xAA" => '&#536;',
63 "\xAB" => '&#171;',
64 "\xAC" => '&#377;',
65 "\xAD" => '&#173;',
66 "\xAE" => '&#378;',
67 "\xAF" => '&#379;',
68 "\xB0" => '&#176;',
69 "\xB1" => '&#177;',
70 "\xB2" => '&#268;',
71 "\xB3" => '&#322;',
72 "\xB4" => '&#381;',
73 "\xB5" => '&#8221;',
74 "\xB6" => '&#182;',
75 "\xB7" => '&#183;',
76 "\xB8" => '&#382;',
77 "\xB9" => '&#269;',
78 "\xBA" => '&#537;',
79 "\xBB" => '&#187;',
80 "\xBC" => '&#338;',
81 "\xBD" => '&#339;',
82 "\xBE" => '&#376;',
83 "\xBF" => '&#380;',
84 "\xC0" => '&#192;',
85 "\xC1" => '&#193;',
86 "\xC2" => '&#194;',
87 "\xC3" => '&#258;',
88 "\xC4" => '&#196;',
89 "\xC5" => '&#262;',
90 "\xC6" => '&#198;',
91 "\xC7" => '&#199;',
92 "\xC8" => '&#200;',
93 "\xC9" => '&#201;',
94 "\xCA" => '&#202;',
95 "\xCB" => '&#203;',
96 "\xCC" => '&#204;',
97 "\xCD" => '&#205;',
98 "\xCE" => '&#206;',
99 "\xCF" => '&#207;',
100 "\xD0" => '&#272;',
101 "\xD1" => '&#323;',
102 "\xD2" => '&#210;',
103 "\xD3" => '&#211;',
104 "\xD4" => '&#212;',
105 "\xD5" => '&#336;',
106 "\xD6" => '&#214;',
107 "\xD7" => '&#346;',
108 "\xD8" => '&#368;',
109 "\xD9" => '&#217;',
110 "\xDA" => '&#218;',
111 "\xDB" => '&#219;',
112 "\xDC" => '&#220;',
113 "\xDD" => '&#280;',
114 "\xDE" => '&#538;',
115 "\xDF" => '&#223;',
116 "\xE0" => '&#224;',
117 "\xE1" => '&#225;',
118 "\xE2" => '&#226;',
119 "\xE3" => '&#259;',
120 "\xE4" => '&#228;',
121 "\xE5" => '&#263;',
122 "\xE6" => '&#230;',
123 "\xE7" => '&#231;',
124 "\xE8" => '&#232;',
125 "\xE9" => '&#233;',
126 "\xEA" => '&#234;',
127 "\xEB" => '&#235;',
128 "\xEC" => '&#236;',
129 "\xED" => '&#237;',
130 "\xEE" => '&#238;',
131 "\xEF" => '&#239;',
132 "\xF0" => '&#273;',
133 "\xF1" => '&#324;',
134 "\xF2" => '&#242;',
135 "\xF3" => '&#243;',
136 "\xF4" => '&#244;',
137 "\xF5" => '&#337;',
138 "\xF6" => '&#246;',
139 "\xF7" => '&#347;',
140 "\xF8" => '&#369;',
141 "\xF9" => '&#249;',
142 "\xFA" => '&#250;',
143 "\xFB" => '&#251;',
144 "\xFC" => '&#252;',
145 "\xFD" => '&#281;',
146 "\xFE" => '&#539;',
147 "\xFF" => '&#255;'
148 );
149
150 $string = str_replace(array_keys($iso8859_16), array_values($iso8859_16), $string);
151
152 return $string;
153 }
154
155 ?>