Fixed dates in copyright. added koi8-r and koi8-u decoding. fixed ereg in
[squirrelmail.git] / functions / decode / iso8859-5.php
CommitLineData
d672fcab 1<?php
2/*
3 * decode/iso8859-5.php
4 * $Id$
5 *
0a708025 6 * Copyright (c) 2003 The SquirrelMail Project Team
d672fcab 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 *
39 */
40function charset_decode_iso8859_5 ($string) {
41 global $default_charset;
42
43 if (strtolower($default_charset) == 'iso-8859-5')
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_5 = array(
52 "\xA0" => '&#160;',
53 "\xA1" => '&#1025;',
54 "\xA2" => '&#1026;',
55 "\xA3" => '&#1027;',
56 "\xA4" => '&#1028;',
57 "\xA5" => '&#1029;',
58 "\xA6" => '&#1030;',
59 "\xA7" => '&#1031;',
60 "\xA8" => '&#1032;',
61 "\xA9" => '&#1033;',
62 "\xAA" => '&#1034;',
63 "\xAB" => '&#1035;',
64 "\xAC" => '&#1036;',
65 "\xAD" => '&#173;',
66 "\xAE" => '&#1038;',
67 "\xAF" => '&#1039;',
68 "\xB0" => '&#1040;',
69 "\xB1" => '&#1041;',
70 "\xB2" => '&#1042;',
71 "\xB3" => '&#1043;',
72 "\xB4" => '&#1044;',
73 "\xB5" => '&#1045;',
74 "\xB6" => '&#1046;',
75 "\xB7" => '&#1047;',
76 "\xB8" => '&#1048;',
77 "\xB9" => '&#1049;',
78 "\xBA" => '&#1050;',
79 "\xBB" => '&#1051;',
80 "\xBC" => '&#1052;',
81 "\xBD" => '&#1053;',
82 "\xBE" => '&#1054;',
83 "\xBF" => '&#1055;',
84 "\xC0" => '&#1056;',
85 "\xC1" => '&#1057;',
86 "\xC2" => '&#1058;',
87 "\xC3" => '&#1059;',
88 "\xC4" => '&#1060;',
89 "\xC5" => '&#1061;',
90 "\xC6" => '&#1062;',
91 "\xC7" => '&#1063;',
92 "\xC8" => '&#1064;',
93 "\xC9" => '&#1065;',
94 "\xCA" => '&#1066;',
95 "\xCB" => '&#1067;',
96 "\xCC" => '&#1068;',
97 "\xCD" => '&#1069;',
98 "\xCE" => '&#1070;',
99 "\xCF" => '&#1071;',
100 "\xD0" => '&#1072;',
101 "\xD1" => '&#1073;',
102 "\xD2" => '&#1074;',
103 "\xD3" => '&#1075;',
104 "\xD4" => '&#1076;',
105 "\xD5" => '&#1077;',
106 "\xD6" => '&#1078;',
107 "\xD7" => '&#1079;',
108 "\xD8" => '&#1080;',
109 "\xD9" => '&#1081;',
110 "\xDA" => '&#1082;',
111 "\xDB" => '&#1083;',
112 "\xDC" => '&#1084;',
113 "\xDD" => '&#1085;',
114 "\xDE" => '&#1086;',
115 "\xDF" => '&#1087;',
116 "\xE0" => '&#1088;',
117 "\xE1" => '&#1089;',
118 "\xE2" => '&#1090;',
119 "\xE3" => '&#1091;',
120 "\xE4" => '&#1092;',
121 "\xE5" => '&#1093;',
122 "\xE6" => '&#1094;',
123 "\xE7" => '&#1095;',
124 "\xE8" => '&#1096;',
125 "\xE9" => '&#1097;',
126 "\xEA" => '&#1098;',
127 "\xEB" => '&#1099;',
128 "\xEC" => '&#1100;',
129 "\xED" => '&#1101;',
130 "\xEE" => '&#1102;',
131 "\xEF" => '&#1103;',
132 "\xF0" => '&#8470;',
133 "\xF1" => '&#1105;',
134 "\xF2" => '&#1106;',
135 "\xF3" => '&#1107;',
136 "\xF4" => '&#1108;',
137 "\xF5" => '&#1109;',
138 "\xF6" => '&#1110;',
139 "\xF7" => '&#1111;',
140 "\xF8" => '&#1112;',
141 "\xF9" => '&#1113;',
142 "\xFA" => '&#1114;',
143 "\xFB" => '&#1115;',
144 "\xFC" => '&#1116;',
145 "\xFD" => '&#167;',
146 "\xFE" => '&#1118;',
147 "\xFF" => '&#1119;'
148 );
149
150 $string = str_replace(array_keys($iso8859_5), array_values($iso8859_5), $string);
151
152 return $string;
153}
154
155?>