Replacing tabs with spaces, trimming white space at EOL and newline at EOF
[squirrelmail.git] / functions / decode / iso_8859_5.php
1 <?php
2 /**
3 * decode/iso8859-5.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-5 decoding function that is needed to read
9 * iso-8859-5 encoded mails in non-iso-8859-5 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-5.TXT
13 *
14 * Name: ISO 8859-5:1999 to Unicode
15 * Unicode version: 3.0
16 * Table version: 1.0
17 * Table format: Format A
18 * Date: 1999 July 27
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-5 encoded string
45 * @param string $string Encoded string
46 * @return string $string Decoded string
47 */
48 function charset_decode_iso_8859_5 ($string) {
49 global $default_charset;
50
51 if (strtolower($default_charset) == 'iso-8859-5')
52 return $string;
53
54 // don't do decoding when there are no 8bit symbols
55 if (! sq_is8bit($string,'iso-8859-5'))
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 ?>