Makes managing decoding easier. Mac decoding moved to separate cvs module
[squirrelmail.git] / functions / decode / iso_8859_2.php
1 <?php
2 /**
3 * decode/iso8859-2.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-2 decoding function that is needed to read
10 * iso-8859-2 encoded mails in non-iso-8859-2 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-2.TXT
14 *
15 * Name: ISO 8859-2: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: 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 * @package squirrelmail
39 * @subpackage decode
40 */
41
42 /**
43 * Decode iso8859-2 encoded string
44 * @param string $string Encoded string
45 * @return string $string Decoded string
46 */
47 function charset_decode_iso_8859_2 ($string) {
48 global $default_charset;
49
50 if (strtolower($default_charset) == 'iso-8859-2')
51 return $string;
52
53 /* Only do the slow convert if there are 8-bit characters */
54 /* there is no 0x80-0x9F letters in ISO8859-* */
55 if ( ! ereg("[\241-\377]", $string) )
56 return $string;
57
58 $iso8859_2 = array(
59 "\xA0" => '&#160;',
60 "\xA1" => '&#260;',
61 "\xA2" => '&#728;',
62 "\xA3" => '&#321;',
63 "\xA4" => '&#164;',
64 "\xA5" => '&#317;',
65 "\xA6" => '&#346;',
66 "\xA7" => '&#167;',
67 "\xA8" => '&#168;',
68 "\xA9" => '&#352;',
69 "\xAA" => '&#350;',
70 "\xAB" => '&#356;',
71 "\xAC" => '&#377;',
72 "\xAD" => '&#173;',
73 "\xAE" => '&#381;',
74 "\xAF" => '&#379;',
75 "\xB0" => '&#176;',
76 "\xB1" => '&#261;',
77 "\xB2" => '&#731;',
78 "\xB3" => '&#322;',
79 "\xB4" => '&#180;',
80 "\xB5" => '&#318;',
81 "\xB6" => '&#347;',
82 "\xB7" => '&#711;',
83 "\xB8" => '&#184;',
84 "\xB9" => '&#353;',
85 "\xBA" => '&#351;',
86 "\xBB" => '&#357;',
87 "\xBC" => '&#378;',
88 "\xBD" => '&#733;',
89 "\xBE" => '&#382;',
90 "\xBF" => '&#380;',
91 "\xC0" => '&#340;',
92 "\xC1" => '&#193;',
93 "\xC2" => '&#194;',
94 "\xC3" => '&#258;',
95 "\xC4" => '&#196;',
96 "\xC5" => '&#313;',
97 "\xC6" => '&#262;',
98 "\xC7" => '&#199;',
99 "\xC8" => '&#268;',
100 "\xC9" => '&#201;',
101 "\xCA" => '&#280;',
102 "\xCB" => '&#203;',
103 "\xCC" => '&#282;',
104 "\xCD" => '&#205;',
105 "\xCE" => '&#206;',
106 "\xCF" => '&#270;',
107 "\xD0" => '&#272;',
108 "\xD1" => '&#323;',
109 "\xD2" => '&#327;',
110 "\xD3" => '&#211;',
111 "\xD4" => '&#212;',
112 "\xD5" => '&#336;',
113 "\xD6" => '&#214;',
114 "\xD7" => '&#215;',
115 "\xD8" => '&#344;',
116 "\xD9" => '&#366;',
117 "\xDA" => '&#218;',
118 "\xDB" => '&#368;',
119 "\xDC" => '&#220;',
120 "\xDD" => '&#221;',
121 "\xDE" => '&#354;',
122 "\xDF" => '&#223;',
123 "\xE0" => '&#341;',
124 "\xE1" => '&#225;',
125 "\xE2" => '&#226;',
126 "\xE3" => '&#259;',
127 "\xE4" => '&#228;',
128 "\xE5" => '&#314;',
129 "\xE6" => '&#263;',
130 "\xE7" => '&#231;',
131 "\xE8" => '&#269;',
132 "\xE9" => '&#233;',
133 "\xEA" => '&#281;',
134 "\xEB" => '&#235;',
135 "\xEC" => '&#283;',
136 "\xED" => '&#237;',
137 "\xEE" => '&#238;',
138 "\xEF" => '&#271;',
139 "\xF0" => '&#273;',
140 "\xF1" => '&#324;',
141 "\xF2" => '&#328;',
142 "\xF3" => '&#243;',
143 "\xF4" => '&#244;',
144 "\xF5" => '&#337;',
145 "\xF6" => '&#246;',
146 "\xF7" => '&#247;',
147 "\xF8" => '&#345;',
148 "\xF9" => '&#367;',
149 "\xFA" => '&#250;',
150 "\xFB" => '&#369;',
151 "\xFC" => '&#252;',
152 "\xFD" => '&#253;',
153 "\xFE" => '&#355;',
154 "\xFF" => '&#729;'
155 );
156
157 $string = str_replace(array_keys($iso8859_2), array_values($iso8859_2), $string);
158
159 return $string;
160 }
161
162 ?>