using sq_is8bit function instead of ereg. Code reuse and fixes some problems
[squirrelmail.git] / functions / decode / iso_8859_11.php
CommitLineData
d672fcab 1<?php
d6c32258 2/**
d672fcab 3 * decode/iso8859-11.php
d672fcab 4 *
82d304a0 5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
d672fcab 6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This file contains iso-8859-11 decoding function that is needed to read
9 * iso-8859-11 encoded mails in non-iso-8859-11 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-11.TXT
13 *
14 * Name: ISO/IEC 8859-11:2001 to Unicode
15 * Unicode version: 3.2
16 * Table version: 1.0
17 * Table format: Format A
18 * Date: 2002 October 7
19 * Authors: Ken Whistler <kenw@sybase.com>
20 *
21 * Original copyright:
22 * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
23 *
24 * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
25 * No claims are made as to fitness for any particular purpose. No
26 * warranties of any kind are expressed or implied. The recipient
27 * agrees to determine applicability of information provided. If this
28 * file has been provided on optical media by Unicode, Inc., the sole
29 * remedy for any claim will be exchange of defective media within 90
30 * days of receipt.
31 *
32 * Unicode, Inc. hereby grants the right to freely use the information
33 * supplied in this file in the creation of products supporting the
34 * Unicode Standard, and to make copies of this file in any form for
35 * internal or external distribution as long as this notice remains
36 * attached.
31841a9e 37 *
38 * @version $Id$
d6c32258 39 * @package squirrelmail
40 * @subpackage decode
41 */
42
43/**
44 * Decode iso8859-11 string
45 * @param string $string Encoded string
46 * @return string $string Decoded string
d672fcab 47 */
df8c4d6d 48function charset_decode_iso_8859_11 ($string) {
d672fcab 49 global $default_charset;
50
51 if (strtolower($default_charset) == 'iso-8859-11')
52 return $string;
53
e53c9681 54 // don't do decoding when there are no 8bit symbols
55 if (! sq_is8bit($string,'iso-8859-11'))
d672fcab 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
d6c32258 154?>