a5668ca6335660be1e3a143d6c1ddc9b49a33ec3
[squirrelmail.git] / functions / decode / iso_8859_8.php
1 <?php
2 /**
3 * decode/iso8859-8.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-8 decoding function that is needed to read
9 * iso-8859-8 encoded mails in non-iso-8859-8 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-8.TXT
13 *
14 * Name: ISO/IEC 8859-8:1999 to Unicode
15 * Unicode version: 3.0
16 * Table version: 1.1
17 * Table format: Format A
18 * Date: 2000-Jan-03
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-8 encoded strings
45 * @param string $string Encoded string
46 * @return string $string Decoded string
47 */
48 function charset_decode_iso_8859_8 ($string) {
49 global $default_charset;
50
51 if (strtolower($default_charset) == 'iso8859-8')
52 return $string;
53
54 // don't do decoding when there are no 8bit symbols
55 if (! sq_is8bit($string,'iso-8859-8'))
56 return $string;
57
58 $iso8859_8 = array(
59 "\xA0" => '&#160;',
60 "\xA2" => '&#162;',
61 "\xA3" => '&#163;',
62 "\xA4" => '&#164;',
63 "\xA5" => '&#165;',
64 "\xA6" => '&#166;',
65 "\xA7" => '&#167;',
66 "\xA8" => '&#168;',
67 "\xA9" => '&#169;',
68 "\xAA" => '&#215;',
69 "\xAB" => '&#171;',
70 "\xAC" => '&#172;',
71 "\xAD" => '&#173;',
72 "\xAE" => '&#174;',
73 "\xAF" => '&#175;',
74 "\xB0" => '&#176;',
75 "\xB1" => '&#177;',
76 "\xB2" => '&#178;',
77 "\xB3" => '&#179;',
78 "\xB4" => '&#180;',
79 "\xB5" => '&#181;',
80 "\xB6" => '&#182;',
81 "\xB7" => '&#183;',
82 "\xB8" => '&#184;',
83 "\xB9" => '&#185;',
84 "\xBA" => '&#247;',
85 "\xBB" => '&#187;',
86 "\xBC" => '&#188;',
87 "\xBD" => '&#189;',
88 "\xBE" => '&#190;',
89 "\xDF" => '&#8215;',
90 "\xE0" => '&#1488;',
91 "\xE1" => '&#1489;',
92 "\xE2" => '&#1490;',
93 "\xE3" => '&#1491;',
94 "\xE4" => '&#1492;',
95 "\xE5" => '&#1493;',
96 "\xE6" => '&#1494;',
97 "\xE7" => '&#1495;',
98 "\xE8" => '&#1496;',
99 "\xE9" => '&#1497;',
100 "\xEA" => '&#1498;',
101 "\xEB" => '&#1499;',
102 "\xEC" => '&#1500;',
103 "\xED" => '&#1501;',
104 "\xEE" => '&#1502;',
105 "\xEF" => '&#1503;',
106 "\xF0" => '&#1504;',
107 "\xF1" => '&#1505;',
108 "\xF2" => '&#1506;',
109 "\xF3" => '&#1507;',
110 "\xF4" => '&#1508;',
111 "\xF5" => '&#1509;',
112 "\xF6" => '&#1510;',
113 "\xF7" => '&#1511;',
114 "\xF8" => '&#1512;',
115 "\xF9" => '&#1513;',
116 "\xFA" => '&#1514;',
117 "\xFD" => '&#8206;',
118 "\xFE" => '&#8207;'
119 );
120
121 $string = str_replace(array_keys($iso8859_8), array_values($iso8859_8), $string);
122
123 return $string;
124 }
125 ?>