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