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