9cf87bf74733c3affcb68824cab5972dea3d9219
[squirrelmail.git] / functions / decode / cp1254.php
1 <?php
2
3 /**
4 * decode/cp1254.php
5 *
6 * This file contains cp1254 decoding function that is needed to read
7 * cp1254 encoded mails in non-cp1254 locale.
8 *
9 * Original data taken from:
10 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1254.TXT
11 *
12 * Name: cp1254 to Unicode table
13 * Unicode version: 2.0
14 * Table version: 2.01
15 * Table format: Format A
16 * Date: 04/15/98
17 * Contact: cpxlate@microsoft.com
18 *
19 * @copyright 2003-2019 The SquirrelMail Project Team
20 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
21 * @version $Id$
22 * @package squirrelmail
23 * @subpackage decode
24 */
25
26 /**
27 * Decode cp1254-encoded string
28 * @param string $string Encoded string
29 * @return string $string Decoded string
30 */
31 function charset_decode_cp1254 ($string) {
32 // don't do decoding when there are no 8bit symbols
33 if (! sq_is8bit($string,'windows-1254'))
34 return $string;
35
36 $cp1254 = array(
37 "\x80" => '&#8364;',
38 "\x81" => '&#65533;',
39 "\x82" => '&#8218;',
40 "\x83" => '&#402;',
41 "\x84" => '&#8222;',
42 "\x85" => '&#8230;',
43 "\x86" => '&#8224;',
44 "\x87" => '&#8225;',
45 "\x88" => '&#710;',
46 "\x89" => '&#8240;',
47 "\x8A" => '&#352;',
48 "\x8B" => '&#8249;',
49 "\x8C" => '&#338;',
50 "\x8D" => '&#65533;',
51 "\x8E" => '&#65533;',
52 "\x8F" => '&#65533;',
53 "\x90" => '&#65533;',
54 "\x91" => '&#8216;',
55 "\x92" => '&#8217;',
56 "\x93" => '&#8220;',
57 "\x94" => '&#8221;',
58 "\x95" => '&#8226;',
59 "\x96" => '&#8211;',
60 "\x97" => '&#8212;',
61 "\x98" => '&#732;',
62 "\x99" => '&#8482;',
63 "\x9A" => '&#353;',
64 "\x9B" => '&#8250;',
65 "\x9C" => '&#339;',
66 "\x9D" => '&#65533;',
67 "\x9E" => '&#65533;',
68 "\x9F" => '&#376;',
69 "\xA0" => '&#160;',
70 "\xA1" => '&#161;',
71 "\xA2" => '&#162;',
72 "\xA3" => '&#163;',
73 "\xA4" => '&#164;',
74 "\xA5" => '&#165;',
75 "\xA6" => '&#166;',
76 "\xA7" => '&#167;',
77 "\xA8" => '&#168;',
78 "\xA9" => '&#169;',
79 "\xAA" => '&#170;',
80 "\xAB" => '&#171;',
81 "\xAC" => '&#172;',
82 "\xAD" => '&#173;',
83 "\xAE" => '&#174;',
84 "\xAF" => '&#175;',
85 "\xB0" => '&#176;',
86 "\xB1" => '&#177;',
87 "\xB2" => '&#178;',
88 "\xB3" => '&#179;',
89 "\xB4" => '&#180;',
90 "\xB5" => '&#181;',
91 "\xB6" => '&#182;',
92 "\xB7" => '&#183;',
93 "\xB8" => '&#184;',
94 "\xB9" => '&#185;',
95 "\xBA" => '&#186;',
96 "\xBB" => '&#187;',
97 "\xBC" => '&#188;',
98 "\xBD" => '&#189;',
99 "\xBE" => '&#190;',
100 "\xBF" => '&#191;',
101 "\xC0" => '&#192;',
102 "\xC1" => '&#193;',
103 "\xC2" => '&#194;',
104 "\xC3" => '&#195;',
105 "\xC4" => '&#196;',
106 "\xC5" => '&#197;',
107 "\xC6" => '&#198;',
108 "\xC7" => '&#199;',
109 "\xC8" => '&#200;',
110 "\xC9" => '&#201;',
111 "\xCA" => '&#202;',
112 "\xCB" => '&#203;',
113 "\xCC" => '&#204;',
114 "\xCD" => '&#205;',
115 "\xCE" => '&#206;',
116 "\xCF" => '&#207;',
117 "\xD0" => '&#286;',
118 "\xD1" => '&#209;',
119 "\xD2" => '&#210;',
120 "\xD3" => '&#211;',
121 "\xD4" => '&#212;',
122 "\xD5" => '&#213;',
123 "\xD6" => '&#214;',
124 "\xD7" => '&#215;',
125 "\xD8" => '&#216;',
126 "\xD9" => '&#217;',
127 "\xDA" => '&#218;',
128 "\xDB" => '&#219;',
129 "\xDC" => '&#220;',
130 "\xDD" => '&#304;',
131 "\xDE" => '&#350;',
132 "\xDF" => '&#223;',
133 "\xE0" => '&#224;',
134 "\xE1" => '&#225;',
135 "\xE2" => '&#226;',
136 "\xE3" => '&#227;',
137 "\xE4" => '&#228;',
138 "\xE5" => '&#229;',
139 "\xE6" => '&#230;',
140 "\xE7" => '&#231;',
141 "\xE8" => '&#232;',
142 "\xE9" => '&#233;',
143 "\xEA" => '&#234;',
144 "\xEB" => '&#235;',
145 "\xEC" => '&#236;',
146 "\xED" => '&#237;',
147 "\xEE" => '&#238;',
148 "\xEF" => '&#239;',
149 "\xF0" => '&#287;',
150 "\xF1" => '&#241;',
151 "\xF2" => '&#242;',
152 "\xF3" => '&#243;',
153 "\xF4" => '&#244;',
154 "\xF5" => '&#245;',
155 "\xF6" => '&#246;',
156 "\xF7" => '&#247;',
157 "\xF8" => '&#248;',
158 "\xF9" => '&#249;',
159 "\xFA" => '&#250;',
160 "\xFB" => '&#251;',
161 "\xFC" => '&#252;',
162 "\xFD" => '&#305;',
163 "\xFE" => '&#351;',
164 "\xFF" => '&#255;'
165 );
166
167 $string = str_replace(array_keys($cp1254), array_values($cp1254), $string);
168
169 return $string;
170 }