bf4fea41cab718a2b1edd7e6892cbf12afecb66e
[squirrelmail.git] / functions / decode / iso_8859_5.php
1 <?php
2 /**
3 * decode/iso8859-5.php
4 * $Id$
5 *
6 * Copyright (c) 2003-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file contains iso-8859-5 decoding function that is needed to read
10 * iso-8859-5 encoded mails in non-iso-8859-5 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-5.TXT
14 *
15 * Name: ISO 8859-5:1999 to Unicode
16 * Unicode version: 3.0
17 * Table version: 1.0
18 * Table format: Format A
19 * Date: 1999 July 27
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 * @package squirrelmail
39 * @subpackage decode
40 */
41
42 /**
43 * Decode iso8859-5 encoded string
44 * @param string $string Encoded string
45 * @return string $string Decoded string
46 */
47 function charset_decode_iso_8859_5 ($string) {
48 global $default_charset;
49
50 if (strtolower($default_charset) == 'iso-8859-5')
51 return $string;
52
53 /* Only do the slow convert if there are 8-bit characters */
54 /* there is no 0x80-0x9F letters in ISO8859-* */
55 if ( ! ereg("[\241-\377]", $string) )
56 return $string;
57
58 $iso8859_5 = array(
59 "\xA0" => '&#160;',
60 "\xA1" => '&#1025;',
61 "\xA2" => '&#1026;',
62 "\xA3" => '&#1027;',
63 "\xA4" => '&#1028;',
64 "\xA5" => '&#1029;',
65 "\xA6" => '&#1030;',
66 "\xA7" => '&#1031;',
67 "\xA8" => '&#1032;',
68 "\xA9" => '&#1033;',
69 "\xAA" => '&#1034;',
70 "\xAB" => '&#1035;',
71 "\xAC" => '&#1036;',
72 "\xAD" => '&#173;',
73 "\xAE" => '&#1038;',
74 "\xAF" => '&#1039;',
75 "\xB0" => '&#1040;',
76 "\xB1" => '&#1041;',
77 "\xB2" => '&#1042;',
78 "\xB3" => '&#1043;',
79 "\xB4" => '&#1044;',
80 "\xB5" => '&#1045;',
81 "\xB6" => '&#1046;',
82 "\xB7" => '&#1047;',
83 "\xB8" => '&#1048;',
84 "\xB9" => '&#1049;',
85 "\xBA" => '&#1050;',
86 "\xBB" => '&#1051;',
87 "\xBC" => '&#1052;',
88 "\xBD" => '&#1053;',
89 "\xBE" => '&#1054;',
90 "\xBF" => '&#1055;',
91 "\xC0" => '&#1056;',
92 "\xC1" => '&#1057;',
93 "\xC2" => '&#1058;',
94 "\xC3" => '&#1059;',
95 "\xC4" => '&#1060;',
96 "\xC5" => '&#1061;',
97 "\xC6" => '&#1062;',
98 "\xC7" => '&#1063;',
99 "\xC8" => '&#1064;',
100 "\xC9" => '&#1065;',
101 "\xCA" => '&#1066;',
102 "\xCB" => '&#1067;',
103 "\xCC" => '&#1068;',
104 "\xCD" => '&#1069;',
105 "\xCE" => '&#1070;',
106 "\xCF" => '&#1071;',
107 "\xD0" => '&#1072;',
108 "\xD1" => '&#1073;',
109 "\xD2" => '&#1074;',
110 "\xD3" => '&#1075;',
111 "\xD4" => '&#1076;',
112 "\xD5" => '&#1077;',
113 "\xD6" => '&#1078;',
114 "\xD7" => '&#1079;',
115 "\xD8" => '&#1080;',
116 "\xD9" => '&#1081;',
117 "\xDA" => '&#1082;',
118 "\xDB" => '&#1083;',
119 "\xDC" => '&#1084;',
120 "\xDD" => '&#1085;',
121 "\xDE" => '&#1086;',
122 "\xDF" => '&#1087;',
123 "\xE0" => '&#1088;',
124 "\xE1" => '&#1089;',
125 "\xE2" => '&#1090;',
126 "\xE3" => '&#1091;',
127 "\xE4" => '&#1092;',
128 "\xE5" => '&#1093;',
129 "\xE6" => '&#1094;',
130 "\xE7" => '&#1095;',
131 "\xE8" => '&#1096;',
132 "\xE9" => '&#1097;',
133 "\xEA" => '&#1098;',
134 "\xEB" => '&#1099;',
135 "\xEC" => '&#1100;',
136 "\xED" => '&#1101;',
137 "\xEE" => '&#1102;',
138 "\xEF" => '&#1103;',
139 "\xF0" => '&#8470;',
140 "\xF1" => '&#1105;',
141 "\xF2" => '&#1106;',
142 "\xF3" => '&#1107;',
143 "\xF4" => '&#1108;',
144 "\xF5" => '&#1109;',
145 "\xF6" => '&#1110;',
146 "\xF7" => '&#1111;',
147 "\xF8" => '&#1112;',
148 "\xF9" => '&#1113;',
149 "\xFA" => '&#1114;',
150 "\xFB" => '&#1115;',
151 "\xFC" => '&#1116;',
152 "\xFD" => '&#167;',
153 "\xFE" => '&#1118;',
154 "\xFF" => '&#1119;'
155 );
156
157 $string = str_replace(array_keys($iso8859_5), array_values($iso8859_5), $string);
158
159 return $string;
160 }
161
162 ?>