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