Minor cleanups
[squirrelmail.git] / functions / decode / iso_8859_13.php
1 <?php
2 /**
3 * decode/iso8859-13.php
4 *
5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This file contains iso-8859-13 decoding function that is needed to read
9 * iso-8859-13 encoded mails in non-iso-8859-13 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-13.TXT
13 *
14 * Name: ISO/IEC 8859-13:1998 to Unicode
15 * Unicode version: 3.0
16 * Table version: 1.0
17 * Table format: Format A
18 * Date: 1999 July 27
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.
37 *
38 * @version $Id$
39 * @package squirrelmail
40 * @subpackage decode
41 */
42
43 /**
44 * Decode iso8859-13
45 * @param string $string Encoded string
46 * @return string $string Decoded string
47 */
48 function charset_decode_iso_8859_13 ($string) {
49 global $default_charset;
50
51 if (strtolower($default_charset) == 'iso-8859-13')
52 return $string;
53
54 /* Only do the slow convert if there are 8-bit characters */
55 /* there is no 0x80-0x9F letters in ISO8859-* */
56 if ( ! ereg("[\241-\377]", $string) )
57 return $string;
58
59 $iso8859_13 = array(
60 "\xA0" => '&#160;',
61 "\xA1" => '&#8221;',
62 "\xA2" => '&#162;',
63 "\xA3" => '&#163;',
64 "\xA4" => '&#164;',
65 "\xA5" => '&#8222;',
66 "\xA6" => '&#166;',
67 "\xA7" => '&#167;',
68 "\xA8" => '&#216;',
69 "\xA9" => '&#169;',
70 "\xAA" => '&#342;',
71 "\xAB" => '&#171;',
72 "\xAC" => '&#172;',
73 "\xAD" => '&#173;',
74 "\xAE" => '&#174;',
75 "\xAF" => '&#198;',
76 "\xB0" => '&#176;',
77 "\xB1" => '&#177;',
78 "\xB2" => '&#178;',
79 "\xB3" => '&#179;',
80 "\xB4" => '&#8220;',
81 "\xB5" => '&#181;',
82 "\xB6" => '&#182;',
83 "\xB7" => '&#183;',
84 "\xB8" => '&#248;',
85 "\xB9" => '&#185;',
86 "\xBA" => '&#343;',
87 "\xBB" => '&#187;',
88 "\xBC" => '&#188;',
89 "\xBD" => '&#189;',
90 "\xBE" => '&#190;',
91 "\xBF" => '&#230;',
92 "\xC0" => '&#260;',
93 "\xC1" => '&#302;',
94 "\xC2" => '&#256;',
95 "\xC3" => '&#262;',
96 "\xC4" => '&#196;',
97 "\xC5" => '&#197;',
98 "\xC6" => '&#280;',
99 "\xC7" => '&#274;',
100 "\xC8" => '&#268;',
101 "\xC9" => '&#201;',
102 "\xCA" => '&#377;',
103 "\xCB" => '&#278;',
104 "\xCC" => '&#290;',
105 "\xCD" => '&#310;',
106 "\xCE" => '&#298;',
107 "\xCF" => '&#315;',
108 "\xD0" => '&#352;',
109 "\xD1" => '&#323;',
110 "\xD2" => '&#325;',
111 "\xD3" => '&#211;',
112 "\xD4" => '&#332;',
113 "\xD5" => '&#213;',
114 "\xD6" => '&#214;',
115 "\xD7" => '&#215;',
116 "\xD8" => '&#370;',
117 "\xD9" => '&#321;',
118 "\xDA" => '&#346;',
119 "\xDB" => '&#362;',
120 "\xDC" => '&#220;',
121 "\xDD" => '&#379;',
122 "\xDE" => '&#381;',
123 "\xDF" => '&#223;',
124 "\xE0" => '&#261;',
125 "\xE1" => '&#303;',
126 "\xE2" => '&#257;',
127 "\xE3" => '&#263;',
128 "\xE4" => '&#228;',
129 "\xE5" => '&#229;',
130 "\xE6" => '&#281;',
131 "\xE7" => '&#275;',
132 "\xE8" => '&#269;',
133 "\xE9" => '&#233;',
134 "\xEA" => '&#378;',
135 "\xEB" => '&#279;',
136 "\xEC" => '&#291;',
137 "\xED" => '&#311;',
138 "\xEE" => '&#299;',
139 "\xEF" => '&#316;',
140 "\xF0" => '&#353;',
141 "\xF1" => '&#324;',
142 "\xF2" => '&#326;',
143 "\xF3" => '&#243;',
144 "\xF4" => '&#333;',
145 "\xF5" => '&#245;',
146 "\xF6" => '&#246;',
147 "\xF7" => '&#247;',
148 "\xF8" => '&#371;',
149 "\xF9" => '&#322;',
150 "\xFA" => '&#347;',
151 "\xFB" => '&#363;',
152 "\xFC" => '&#252;',
153 "\xFD" => '&#380;',
154 "\xFE" => '&#382;',
155 "\xFF" => '&#8217;'
156 );
157
158 $string = str_replace(array_keys($iso8859_13), array_values($iso8859_13), $string);
159
160 return $string;
161 }
162
163 ?>