We're living in 2004 now... perl is your friend for these kinds of things :)
[squirrelmail.git] / functions / decode / iso_8859_11.php
1 <?php
2 /**
3 * decode/iso8859-11.php
4 * $Id$
5 *
6 * Copyright (c) 2003-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file contains iso-8859-11 decoding function that is needed to read
10 * iso-8859-11 encoded mails in non-iso-8859-11 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-11.TXT
14 *
15 * Name: ISO/IEC 8859-11:2001 to Unicode
16 * Unicode version: 3.2
17 * Table version: 1.0
18 * Table format: Format A
19 * Date: 2002 October 7
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-11 string
44 * @param string $string Encoded string
45 * @return string $string Decoded string
46 */
47 function charset_decode_iso_8859_11 ($string) {
48 global $default_charset;
49
50 if (strtolower($default_charset) == 'iso-8859-11')
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_11 = array(
59 "\xA0" => '&#160;',
60 "\xA1" => '&#3585;',
61 "\xA2" => '&#3586;',
62 "\xA3" => '&#3587;',
63 "\xA4" => '&#3588;',
64 "\xA5" => '&#3589;',
65 "\xA6" => '&#3590;',
66 "\xA7" => '&#3591;',
67 "\xA8" => '&#3592;',
68 "\xA9" => '&#3593;',
69 "\xAA" => '&#3594;',
70 "\xAB" => '&#3595;',
71 "\xAC" => '&#3596;',
72 "\xAD" => '&#3597;',
73 "\xAE" => '&#3598;',
74 "\xAF" => '&#3599;',
75 "\xB0" => '&#3600;',
76 "\xB1" => '&#3601;',
77 "\xB2" => '&#3602;',
78 "\xB3" => '&#3603;',
79 "\xB4" => '&#3604;',
80 "\xB5" => '&#3605;',
81 "\xB6" => '&#3606;',
82 "\xB7" => '&#3607;',
83 "\xB8" => '&#3608;',
84 "\xB9" => '&#3609;',
85 "\xBA" => '&#3610;',
86 "\xBB" => '&#3611;',
87 "\xBC" => '&#3612;',
88 "\xBD" => '&#3613;',
89 "\xBE" => '&#3614;',
90 "\xBF" => '&#3615;',
91 "\xC0" => '&#3616;',
92 "\xC1" => '&#3617;',
93 "\xC2" => '&#3618;',
94 "\xC3" => '&#3619;',
95 "\xC4" => '&#3620;',
96 "\xC5" => '&#3621;',
97 "\xC6" => '&#3622;',
98 "\xC7" => '&#3623;',
99 "\xC8" => '&#3624;',
100 "\xC9" => '&#3625;',
101 "\xCA" => '&#3626;',
102 "\xCB" => '&#3627;',
103 "\xCC" => '&#3628;',
104 "\xCD" => '&#3629;',
105 "\xCE" => '&#3630;',
106 "\xCF" => '&#3631;',
107 "\xD0" => '&#3632;',
108 "\xD1" => '&#3633;',
109 "\xD2" => '&#3634;',
110 "\xD3" => '&#3635;',
111 "\xD4" => '&#3636;',
112 "\xD5" => '&#3637;',
113 "\xD6" => '&#3638;',
114 "\xD7" => '&#3639;',
115 "\xD8" => '&#3640;',
116 "\xD9" => '&#3641;',
117 "\xDA" => '&#3642;',
118 "\xDF" => '&#3647;',
119 "\xE0" => '&#3648;',
120 "\xE1" => '&#3649;',
121 "\xE2" => '&#3650;',
122 "\xE3" => '&#3651;',
123 "\xE4" => '&#3652;',
124 "\xE5" => '&#3653;',
125 "\xE6" => '&#3654;',
126 "\xE7" => '&#3655;',
127 "\xE8" => '&#3656;',
128 "\xE9" => '&#3657;',
129 "\xEA" => '&#3658;',
130 "\xEB" => '&#3659;',
131 "\xEC" => '&#3660;',
132 "\xED" => '&#3661;',
133 "\xEE" => '&#3662;',
134 "\xEF" => '&#3663;',
135 "\xF0" => '&#3664;',
136 "\xF1" => '&#3665;',
137 "\xF2" => '&#3666;',
138 "\xF3" => '&#3667;',
139 "\xF4" => '&#3668;',
140 "\xF5" => '&#3669;',
141 "\xF6" => '&#3670;',
142 "\xF7" => '&#3671;',
143 "\xF8" => '&#3672;',
144 "\xF9" => '&#3673;',
145 "\xFA" => '&#3674;',
146 "\xFB" => '&#3675;'
147 );
148
149 $string = str_replace(array_keys($iso8859_11), array_values($iso8859_11), $string);
150
151 return $string;
152 }
153
154 ?>