Replacing tabs with spaces, trimming white space at EOL and newline at EOF
[squirrelmail.git] / functions / decode / iso_8859_14.php
1 <?php
2 /**
3 * decode/iso8859-14.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-14 decoding function that is needed to read
9 * iso-8859-14 encoded mails in non-iso-8859-14 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-14.TXT
13 *
14 * Name: ISO/IEC 8859-14: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: Markus Kuhn <mkuhn@acm.org>
20 * 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 *
39 * @version $Id$
40 * @package squirrelmail
41 * @subpackage decode
42 */
43
44 /**
45 * Decode iso8859-14 encoded string
46 * @param string $string Encoded string
47 * @return string $string Decoded string
48 */
49 function charset_decode_iso_8859_14 ($string) {
50 global $default_charset;
51
52 if (strtolower($default_charset) == 'iso-8859-14')
53 return $string;
54
55 // don't do decoding when there are no 8bit symbols
56 if (! sq_is8bit($string,'iso-8859-14'))
57 return $string;
58
59 $iso8859_14 = array(
60 "\xA0" => '&#160;',
61 "\xA1" => '&#7682;',
62 "\xA2" => '&#7683;',
63 "\xA3" => '&#163;',
64 "\xA4" => '&#266;',
65 "\xA5" => '&#267;',
66 "\xA6" => '&#7690;',
67 "\xA7" => '&#167;',
68 "\xA8" => '&#7808;',
69 "\xA9" => '&#169;',
70 "\xAA" => '&#7810;',
71 "\xAB" => '&#7691;',
72 "\xAC" => '&#7922;',
73 "\xAD" => '&#173;',
74 "\xAE" => '&#174;',
75 "\xAF" => '&#376;',
76 "\xB0" => '&#7710;',
77 "\xB1" => '&#7711;',
78 "\xB2" => '&#288;',
79 "\xB3" => '&#289;',
80 "\xB4" => '&#7744;',
81 "\xB5" => '&#7745;',
82 "\xB6" => '&#182;',
83 "\xB7" => '&#7766;',
84 "\xB8" => '&#7809;',
85 "\xB9" => '&#7767;',
86 "\xBA" => '&#7811;',
87 "\xBB" => '&#7776;',
88 "\xBC" => '&#7923;',
89 "\xBD" => '&#7812;',
90 "\xBE" => '&#7813;',
91 "\xBF" => '&#7777;',
92 "\xC0" => '&#192;',
93 "\xC1" => '&#193;',
94 "\xC2" => '&#194;',
95 "\xC3" => '&#195;',
96 "\xC4" => '&#196;',
97 "\xC5" => '&#197;',
98 "\xC6" => '&#198;',
99 "\xC7" => '&#199;',
100 "\xC8" => '&#200;',
101 "\xC9" => '&#201;',
102 "\xCA" => '&#202;',
103 "\xCB" => '&#203;',
104 "\xCC" => '&#204;',
105 "\xCD" => '&#205;',
106 "\xCE" => '&#206;',
107 "\xCF" => '&#207;',
108 "\xD0" => '&#372;',
109 "\xD1" => '&#209;',
110 "\xD2" => '&#210;',
111 "\xD3" => '&#211;',
112 "\xD4" => '&#212;',
113 "\xD5" => '&#213;',
114 "\xD6" => '&#214;',
115 "\xD7" => '&#7786;',
116 "\xD8" => '&#216;',
117 "\xD9" => '&#217;',
118 "\xDA" => '&#218;',
119 "\xDB" => '&#219;',
120 "\xDC" => '&#220;',
121 "\xDD" => '&#221;',
122 "\xDE" => '&#374;',
123 "\xDF" => '&#223;',
124 "\xE0" => '&#224;',
125 "\xE1" => '&#225;',
126 "\xE2" => '&#226;',
127 "\xE3" => '&#227;',
128 "\xE4" => '&#228;',
129 "\xE5" => '&#229;',
130 "\xE6" => '&#230;',
131 "\xE7" => '&#231;',
132 "\xE8" => '&#232;',
133 "\xE9" => '&#233;',
134 "\xEA" => '&#234;',
135 "\xEB" => '&#235;',
136 "\xEC" => '&#236;',
137 "\xED" => '&#237;',
138 "\xEE" => '&#238;',
139 "\xEF" => '&#239;',
140 "\xF0" => '&#373;',
141 "\xF1" => '&#241;',
142 "\xF2" => '&#242;',
143 "\xF3" => '&#243;',
144 "\xF4" => '&#244;',
145 "\xF5" => '&#245;',
146 "\xF6" => '&#246;',
147 "\xF7" => '&#7787;',
148 "\xF8" => '&#248;',
149 "\xF9" => '&#249;',
150 "\xFA" => '&#250;',
151 "\xFB" => '&#251;',
152 "\xFC" => '&#252;',
153 "\xFD" => '&#253;',
154 "\xFE" => '&#375;',
155 "\xFF" => '&#255;'
156 );
157
158 $string = str_replace(array_keys($iso8859_14), array_values($iso8859_14), $string);
159
160 return $string;
161 }
162 ?>