Replacing tabs with spaces, trimming white space at EOL and newline at EOF
[squirrelmail.git] / functions / decode / iso_ir_111.php
1 <?php
2 /**
3 * decode/iso-ir-111.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-ir-111 decoding function that is needed to read
9 * iso-ir-111 encoded mails in non-iso-ir-111 locale.
10 *
11 * Original data taken from:
12 * http://crl.nmsu.edu/~mleisher/csets/ISOIR111.TXT
13 *
14 * Original ID: Id: ISOIR111.TXT,v 1.2 1999/08/23 18:34:15 mleisher Exp
15 * Name: ISO IR 111/ECMA Cyrillic to Unicode 2.1 mapping table.
16 * Typed in by hand from
17 * http://www.fingertipsoft.com/ref/cyrillic/charsets.html
18 * Author: Mark Leisher <mleisher@crl.nmsu.edu>
19 * Date: 05 March 1998
20 *
21 * Original copyright:
22 * Copyright 1999 Computing Research Labs, New Mexico State University
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a
25 * copy of this software and associated documentation files (the ""Software""),
26 * to deal in the Software without restriction, including without limitation
27 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
28 * and/or sell copies of the Software, and to permit persons to whom the
29 * Software is furnished to do so, subject to the following conditions:
30 *
31 * The above copyright notice and this permission notice shall be included in
32 * all copies or substantial portions of the Software.
33 *
34 * THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
37 * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
38 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
39 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
40 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 *
42 * @version $Id$
43 * @package squirrelmail
44 * @subpackage decode
45 */
46
47 /**
48 * Decode iso-ir-111 encoded strings
49 * @param string $string Encoded string
50 * @return string Decoded string
51 */
52 function charset_decode_iso_ir_111 ($string) {
53 global $default_charset;
54
55 if (strtolower($default_charset) == 'iso-ir-111')
56 return $string;
57
58 // don't do decoding when there are no 8bit symbols
59 if (! sq_is8bit($string,'iso-ir-111'))
60 return $string;
61
62 $iso_ir_111 = array(
63 "\xA0" => '&#160;',
64 "\xA1" => '&#1106;',
65 "\xA2" => '&#1107;',
66 "\xA3" => '&#1105;',
67 "\xA4" => '&#1108;',
68 "\xA5" => '&#1109;',
69 "\xA6" => '&#1110;',
70 "\xA7" => '&#1111;',
71 "\xA8" => '&#1112;',
72 "\xA9" => '&#1113;',
73 "\xAA" => '&#1114;',
74 "\xAB" => '&#1115;',
75 "\xAC" => '&#1116;',
76 "\xAD" => '&#173;',
77 "\xAE" => '&#1118;',
78 "\xAF" => '&#1119;',
79 "\xB0" => '&#8470;',
80 "\xB1" => '&#1026;',
81 "\xB2" => '&#1027;',
82 "\xB3" => '&#1025;',
83 "\xB4" => '&#1028;',
84 "\xB5" => '&#1029;',
85 "\xB6" => '&#1030;',
86 "\xB7" => '&#1031;',
87 "\xB8" => '&#1032;',
88 "\xB9" => '&#1033;',
89 "\xBA" => '&#1034;',
90 "\xBB" => '&#1035;',
91 "\xBC" => '&#1036;',
92 "\xBD" => '&#164;',
93 "\xBE" => '&#1038;',
94 "\xBF" => '&#1039;',
95 "\xC0" => '&#1102;',
96 "\xC1" => '&#1072;',
97 "\xC2" => '&#1073;',
98 "\xC3" => '&#1094;',
99 "\xC4" => '&#1076;',
100 "\xC5" => '&#1077;',
101 "\xC6" => '&#1092;',
102 "\xC7" => '&#1075;',
103 "\xC8" => '&#1093;',
104 "\xC9" => '&#1080;',
105 "\xCA" => '&#1081;',
106 "\xCB" => '&#1082;',
107 "\xCC" => '&#1083;',
108 "\xCD" => '&#1084;',
109 "\xCE" => '&#1085;',
110 "\xCF" => '&#1086;',
111 "\xD0" => '&#1087;',
112 "\xD1" => '&#1103;',
113 "\xD2" => '&#1088;',
114 "\xD3" => '&#1089;',
115 "\xD4" => '&#1090;',
116 "\xD5" => '&#1091;',
117 "\xD6" => '&#1078;',
118 "\xD7" => '&#1074;',
119 "\xD8" => '&#1100;',
120 "\xD9" => '&#1099;',
121 "\xDA" => '&#1079;',
122 "\xDB" => '&#1096;',
123 "\xDC" => '&#1101;',
124 "\xDD" => '&#1097;',
125 "\xDE" => '&#1095;',
126 "\xDF" => '&#1098;',
127 "\xE0" => '&#1070;',
128 "\xE1" => '&#1040;',
129 "\xE2" => '&#1041;',
130 "\xE3" => '&#1062;',
131 "\xE4" => '&#1044;',
132 "\xE5" => '&#1045;',
133 "\xE6" => '&#1060;',
134 "\xE7" => '&#1043;',
135 "\xE8" => '&#1061;',
136 "\xE9" => '&#1048;',
137 "\xEA" => '&#1049;',
138 "\xEB" => '&#1050;',
139 "\xEC" => '&#1051;',
140 "\xED" => '&#1052;',
141 "\xEE" => '&#1053;',
142 "\xEF" => '&#1054;',
143 "\xF0" => '&#1055;',
144 "\xF1" => '&#1071;',
145 "\xF2" => '&#1056;',
146 "\xF3" => '&#1057;',
147 "\xF4" => '&#1058;',
148 "\xF5" => '&#1059;',
149 "\xF6" => '&#1046;',
150 "\xF7" => '&#1042;',
151 "\xF8" => '&#1068;',
152 "\xF9" => '&#1067;',
153 "\xFA" => '&#1047;',
154 "\xFB" => '&#1064;',
155 "\xFC" => '&#1069;',
156 "\xFD" => '&#1065;',
157 "\xFE" => '&#1063;',
158 "\xFF" => '&#1066;'
159 );
160
161 $string = str_replace(array_keys($iso_ir_111), array_values($iso_ir_111), $string);
162
163 return $string;
164 }
165 ?>