cd785cd1cef36968021c05fb9dedd1a4382c7130
[squirrelmail.git] / functions / decode / iso_8859_13.php
1 <?php
2
3 /**
4 * decode/iso8859-13.php
5 *
6 * This file contains iso-8859-13 decoding function that is needed to read
7 * iso-8859-13 encoded mails in non-iso-8859-13 locale.
8 *
9 * Original data taken from:
10 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-13.TXT
11 *
12 * Name: ISO/IEC 8859-13:1998 to Unicode
13 * Unicode version: 3.0
14 * Table version: 1.0
15 * Table format: Format A
16 * Date: 1999 July 27
17 * Authors: Ken Whistler <kenw@sybase.com>
18 *
19 * Original copyright:
20 * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
21 *
22 * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
23 * No claims are made as to fitness for any particular purpose. No
24 * warranties of any kind are expressed or implied. The recipient
25 * agrees to determine applicability of information provided. If this
26 * file has been provided on optical media by Unicode, Inc., the sole
27 * remedy for any claim will be exchange of defective media within 90
28 * days of receipt.
29 *
30 * Unicode, Inc. hereby grants the right to freely use the information
31 * supplied in this file in the creation of products supporting the
32 * Unicode Standard, and to make copies of this file in any form for
33 * internal or external distribution as long as this notice remains
34 * attached.
35 *
36 * @copyright 2003-2010 The SquirrelMail Project Team
37 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
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 // don't do decoding when there are no 8bit symbols
50 if (! sq_is8bit($string,'iso-8859-13'))
51 return $string;
52
53 $iso8859_13 = array(
54 "\xA0" => '&#160;',
55 "\xA1" => '&#8221;',
56 "\xA2" => '&#162;',
57 "\xA3" => '&#163;',
58 "\xA4" => '&#164;',
59 "\xA5" => '&#8222;',
60 "\xA6" => '&#166;',
61 "\xA7" => '&#167;',
62 "\xA8" => '&#216;',
63 "\xA9" => '&#169;',
64 "\xAA" => '&#342;',
65 "\xAB" => '&#171;',
66 "\xAC" => '&#172;',
67 "\xAD" => '&#173;',
68 "\xAE" => '&#174;',
69 "\xAF" => '&#198;',
70 "\xB0" => '&#176;',
71 "\xB1" => '&#177;',
72 "\xB2" => '&#178;',
73 "\xB3" => '&#179;',
74 "\xB4" => '&#8220;',
75 "\xB5" => '&#181;',
76 "\xB6" => '&#182;',
77 "\xB7" => '&#183;',
78 "\xB8" => '&#248;',
79 "\xB9" => '&#185;',
80 "\xBA" => '&#343;',
81 "\xBB" => '&#187;',
82 "\xBC" => '&#188;',
83 "\xBD" => '&#189;',
84 "\xBE" => '&#190;',
85 "\xBF" => '&#230;',
86 "\xC0" => '&#260;',
87 "\xC1" => '&#302;',
88 "\xC2" => '&#256;',
89 "\xC3" => '&#262;',
90 "\xC4" => '&#196;',
91 "\xC5" => '&#197;',
92 "\xC6" => '&#280;',
93 "\xC7" => '&#274;',
94 "\xC8" => '&#268;',
95 "\xC9" => '&#201;',
96 "\xCA" => '&#377;',
97 "\xCB" => '&#278;',
98 "\xCC" => '&#290;',
99 "\xCD" => '&#310;',
100 "\xCE" => '&#298;',
101 "\xCF" => '&#315;',
102 "\xD0" => '&#352;',
103 "\xD1" => '&#323;',
104 "\xD2" => '&#325;',
105 "\xD3" => '&#211;',
106 "\xD4" => '&#332;',
107 "\xD5" => '&#213;',
108 "\xD6" => '&#214;',
109 "\xD7" => '&#215;',
110 "\xD8" => '&#370;',
111 "\xD9" => '&#321;',
112 "\xDA" => '&#346;',
113 "\xDB" => '&#362;',
114 "\xDC" => '&#220;',
115 "\xDD" => '&#379;',
116 "\xDE" => '&#381;',
117 "\xDF" => '&#223;',
118 "\xE0" => '&#261;',
119 "\xE1" => '&#303;',
120 "\xE2" => '&#257;',
121 "\xE3" => '&#263;',
122 "\xE4" => '&#228;',
123 "\xE5" => '&#229;',
124 "\xE6" => '&#281;',
125 "\xE7" => '&#275;',
126 "\xE8" => '&#269;',
127 "\xE9" => '&#233;',
128 "\xEA" => '&#378;',
129 "\xEB" => '&#279;',
130 "\xEC" => '&#291;',
131 "\xED" => '&#311;',
132 "\xEE" => '&#299;',
133 "\xEF" => '&#316;',
134 "\xF0" => '&#353;',
135 "\xF1" => '&#324;',
136 "\xF2" => '&#326;',
137 "\xF3" => '&#243;',
138 "\xF4" => '&#333;',
139 "\xF5" => '&#245;',
140 "\xF6" => '&#246;',
141 "\xF7" => '&#247;',
142 "\xF8" => '&#371;',
143 "\xF9" => '&#322;',
144 "\xFA" => '&#347;',
145 "\xFB" => '&#363;',
146 "\xFC" => '&#252;',
147 "\xFD" => '&#380;',
148 "\xFE" => '&#382;',
149 "\xFF" => '&#8217;'
150 );
151
152 $string = str_replace(array_keys($iso8859_13), array_values($iso8859_13), $string);
153
154 return $string;
155 }