Phpdocumentor update - sed is your friend for these kinds of things ;)
[squirrelmail.git] / functions / decode / cp1253.php
CommitLineData
211d912f 1<?php
d6c32258 2/**
211d912f 3 * decode/cp1253.php
211d912f 4 *
82d304a0 5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
211d912f 6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This file contains cp1253 decoding function that is needed to read
9 * cp1253 encoded mails in non-cp1253 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1253.TXT
13 *
14 * Name: cp1253 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
211d912f 24 */
25
d6c32258 26/**
27 * Decode cp1253-encoded string
28 * @param string $string Encoded string
29 * @return string $string Decoded string
30 */
211d912f 31function charset_decode_cp1253 ($string) {
32 global $default_charset;
33
34 if (strtolower($default_charset) == 'windows-1253')
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 $cp1253 = array(
43 "\x80" => '&#8364;',
44 "\x81" => '&#65533;',
45 "\x82" => '&#8218;',
46 "\x83" => '&#402;',
47 "\x84" => '&#8222;',
48 "\x85" => '&#8230;',
49 "\x86" => '&#8224;',
50 "\x87" => '&#8225;',
51 "\x88" => '&#65533;',
52 "\x89" => '&#8240;',
53 "\x8A" => '&#65533;',
54 "\x8B" => '&#8249;',
55 "\x8C" => '&#65533;',
56 "\x8D" => '&#65533;',
57 "\x8E" => '&#65533;',
58 "\x8F" => '&#65533;',
59 "\x90" => '&#65533;',
60 "\x91" => '&#8216;',
61 "\x92" => '&#8217;',
62 "\x93" => '&#8220;',
63 "\x94" => '&#8221;',
64 "\x95" => '&#8226;',
65 "\x96" => '&#8211;',
66 "\x97" => '&#8212;',
67 "\x98" => '&#65533;',
68 "\x99" => '&#8482;',
69 "\x9A" => '&#65533;',
70 "\x9B" => '&#8250;',
71 "\x9C" => '&#65533;',
72 "\x9D" => '&#65533;',
73 "\x9E" => '&#65533;',
74 "\x9F" => '&#65533;',
75 "\xA0" => '&#160;',
76 "\xA1" => '&#901;',
77 "\xA2" => '&#902;',
78 "\xA3" => '&#163;',
79 "\xA4" => '&#164;',
80 "\xA5" => '&#165;',
81 "\xA6" => '&#166;',
82 "\xA7" => '&#167;',
83 "\xA8" => '&#168;',
84 "\xA9" => '&#169;',
85 "\xAA" => '&#65533;',
86 "\xAB" => '&#171;',
87 "\xAC" => '&#172;',
88 "\xAD" => '&#173;',
89 "\xAE" => '&#174;',
90 "\xAF" => '&#8213;',
91 "\xB0" => '&#176;',
92 "\xB1" => '&#177;',
93 "\xB2" => '&#178;',
94 "\xB3" => '&#179;',
95 "\xB4" => '&#900;',
96 "\xB5" => '&#181;',
97 "\xB6" => '&#182;',
98 "\xB7" => '&#183;',
99 "\xB8" => '&#904;',
100 "\xB9" => '&#905;',
101 "\xBA" => '&#906;',
102 "\xBB" => '&#187;',
103 "\xBC" => '&#908;',
104 "\xBD" => '&#189;',
105 "\xBE" => '&#910;',
106 "\xBF" => '&#911;',
107 "\xC0" => '&#912;',
108 "\xC1" => '&#913;',
109 "\xC2" => '&#914;',
110 "\xC3" => '&#915;',
111 "\xC4" => '&#916;',
112 "\xC5" => '&#917;',
113 "\xC6" => '&#918;',
114 "\xC7" => '&#919;',
115 "\xC8" => '&#920;',
116 "\xC9" => '&#921;',
117 "\xCA" => '&#922;',
118 "\xCB" => '&#923;',
119 "\xCC" => '&#924;',
120 "\xCD" => '&#925;',
121 "\xCE" => '&#926;',
122 "\xCF" => '&#927;',
123 "\xD0" => '&#928;',
124 "\xD1" => '&#929;',
125 "\xD2" => '&#65533;',
126 "\xD3" => '&#931;',
127 "\xD4" => '&#932;',
128 "\xD5" => '&#933;',
129 "\xD6" => '&#934;',
130 "\xD7" => '&#935;',
131 "\xD8" => '&#936;',
132 "\xD9" => '&#937;',
133 "\xDA" => '&#938;',
134 "\xDB" => '&#939;',
135 "\xDC" => '&#940;',
136 "\xDD" => '&#941;',
137 "\xDE" => '&#942;',
138 "\xDF" => '&#943;',
139 "\xE0" => '&#944;',
140 "\xE1" => '&#945;',
141 "\xE2" => '&#946;',
142 "\xE3" => '&#947;',
143 "\xE4" => '&#948;',
144 "\xE5" => '&#949;',
145 "\xE6" => '&#950;',
146 "\xE7" => '&#951;',
147 "\xE8" => '&#952;',
148 "\xE9" => '&#953;',
149 "\xEA" => '&#954;',
150 "\xEB" => '&#955;',
151 "\xEC" => '&#956;',
152 "\xED" => '&#957;',
153 "\xEE" => '&#958;',
154 "\xEF" => '&#959;',
155 "\xF0" => '&#960;',
156 "\xF1" => '&#961;',
157 "\xF2" => '&#962;',
158 "\xF3" => '&#963;',
159 "\xF4" => '&#964;',
160 "\xF5" => '&#965;',
161 "\xF6" => '&#966;',
162 "\xF7" => '&#967;',
163 "\xF8" => '&#968;',
164 "\xF9" => '&#969;',
165 "\xFA" => '&#970;',
166 "\xFB" => '&#971;',
167 "\xFC" => '&#972;',
168 "\xFD" => '&#973;',
169 "\xFE" => '&#974;',
170 "\xFF" => '&#65533;'
171 );
172
173 $string = str_replace(array_keys($cp1253), array_values($cp1253), $string);
174
175 return $string;
176}
177
d6c32258 178?>