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