Added separate iso-8859-*, cp1257 and big5 decoding files
[squirrelmail.git] / functions / decode / cp1257.php
1 <?php
2 /*
3 * decode/cp1257.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 cp1257 decoding function that is needed to read
10 * cp1257 encoded mails in non-cp1257 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1257.TXT
14 *
15 * Name: cp1257 to Unicode table
16 * Unicode version: 2.0
17 * Table version: 2.01
18 * Table format: Format A
19 * Date: 04/15/98
20 * Contact: cpxlate@microsoft.com
21 *
22 */
23
24 function charset_decode_cp1257 ($string) {
25 global $default_charset;
26
27 if (strtolower($default_charset) == 'windows-1257')
28 return $string;
29
30 /* Only do the slow convert if there are 8-bit characters */
31 /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
32 if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
33 return $string;
34
35 $cp1257 = array(
36 "\x80" => '&#8364;',
37 "\x82" => '&#8218;',
38 "\x84" => '&#8222;',
39 "\x85" => '&#8230;',
40 "\x86" => '&#8224;',
41 "\x87" => '&#8225;',
42 "\x89" => '&#8240;',
43 "\x8B" => '&#8249;',
44 "\x8D" => '&#168;',
45 "\x8E" => '&#711;',
46 "\x8F" => '&#184;',
47 "\x91" => '&#8216;',
48 "\x92" => '&#8217;',
49 "\x93" => '&#8220;',
50 "\x94" => '&#8221;',
51 "\x95" => '&#8226;',
52 "\x96" => '&#8211;',
53 "\x97" => '&#8212;',
54 "\x99" => '&#8482;',
55 "\x9B" => '&#8250;',
56 "\x9D" => '&#175;',
57 "\x9E" => '&#731;',
58 "\xA0" => '&#160;',
59 "\xA2" => '&#162;',
60 "\xA3" => '&#163;',
61 "\xA4" => '&#164;',
62 "\xA6" => '&#166;',
63 "\xA7" => '&#167;',
64 "\xA8" => '&#216;',
65 "\xA9" => '&#169;',
66 "\xAA" => '&#342;',
67 "\xAB" => '&#171;',
68 "\xAC" => '&#172;',
69 "\xAD" => '&#173;',
70 "\xAE" => '&#174;',
71 "\xAF" => '&#198;',
72 "\xB0" => '&#176;',
73 "\xB1" => '&#177;',
74 "\xB2" => '&#178;',
75 "\xB3" => '&#179;',
76 "\xB4" => '&#180;',
77 "\xB5" => '&#181;',
78 "\xB6" => '&#182;',
79 "\xB7" => '&#183;',
80 "\xB8" => '&#248;',
81 "\xB9" => '&#185;',
82 "\xBA" => '&#343;',
83 "\xBB" => '&#187;',
84 "\xBC" => '&#188;',
85 "\xBD" => '&#189;',
86 "\xBE" => '&#190;',
87 "\xBF" => '&#230;',
88 "\xC0" => '&#260;',
89 "\xC1" => '&#302;',
90 "\xC2" => '&#256;',
91 "\xC3" => '&#262;',
92 "\xC4" => '&#196;',
93 "\xC5" => '&#197;',
94 "\xC6" => '&#280;',
95 "\xC7" => '&#274;',
96 "\xC8" => '&#268;',
97 "\xC9" => '&#201;',
98 "\xCA" => '&#377;',
99 "\xCB" => '&#278;',
100 "\xCC" => '&#290;',
101 "\xCD" => '&#310;',
102 "\xCE" => '&#298;',
103 "\xCF" => '&#315;',
104 "\xD0" => '&#352;',
105 "\xD1" => '&#323;',
106 "\xD2" => '&#325;',
107 "\xD3" => '&#211;',
108 "\xD4" => '&#332;',
109 "\xD5" => '&#213;',
110 "\xD6" => '&#214;',
111 "\xD7" => '&#215;',
112 "\xD8" => '&#370;',
113 "\xD9" => '&#321;',
114 "\xDA" => '&#346;',
115 "\xDB" => '&#362;',
116 "\xDC" => '&#220;',
117 "\xDD" => '&#379;',
118 "\xDE" => '&#381;',
119 "\xDF" => '&#223;',
120 "\xE0" => '&#261;',
121 "\xE1" => '&#303;',
122 "\xE2" => '&#257;',
123 "\xE3" => '&#263;',
124 "\xE4" => '&#228;',
125 "\xE5" => '&#229;',
126 "\xE6" => '&#281;',
127 "\xE7" => '&#275;',
128 "\xE8" => '&#269;',
129 "\xE9" => '&#233;',
130 "\xEA" => '&#378;',
131 "\xEB" => '&#279;',
132 "\xEC" => '&#291;',
133 "\xED" => '&#311;',
134 "\xEE" => '&#299;',
135 "\xEF" => '&#316;',
136 "\xF0" => '&#353;',
137 "\xF1" => '&#324;',
138 "\xF2" => '&#326;',
139 "\xF3" => '&#243;',
140 "\xF4" => '&#333;',
141 "\xF5" => '&#245;',
142 "\xF6" => '&#246;',
143 "\xF7" => '&#247;',
144 "\xF8" => '&#371;',
145 "\xF9" => '&#322;',
146 "\xFA" => '&#347;',
147 "\xFB" => '&#363;',
148 "\xFC" => '&#252;',
149 "\xFD" => '&#380;',
150 "\xFE" => '&#382;',
151 "\xFF" => '&#729;'
152 );
153
154 $string = str_replace(array_keys($cp1257), array_values($cp1257), $string);
155
156 return $string;
157 }
158
159 ?>