using sq_is8bit function instead of ereg. Code reuse and fixes some problems
[squirrelmail.git] / functions / decode / iso_8859_7.php
CommitLineData
d672fcab 1<?php
d6c32258 2/**
d672fcab 3 * decode/iso8859-7.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 iso-8859-7 decoding function that is needed to read
9 * iso-8859-7 encoded mails in non-iso-8859-7 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-7.TXT
13 *
14 * Name: ISO 8859-7:1987 to Unicode
15 * Unicode version: 3.0
16 * Table version: 1.0
17 * Table format: Format A
18 * Date: 1999 July 27
19 * Authors: Ken Whistler <kenw@sybase.com>
20 *
21 * Original copyright:
e53c9681 22 * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
d672fcab 23 *
e53c9681 24 * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
25 * No claims are made as to fitness for any particular purpose. No
26 * warranties of any kind are expressed or implied. The recipient
27 * agrees to determine applicability of information provided. If this
28 * file has been provided on optical media by Unicode, Inc., the sole
29 * remedy for any claim will be exchange of defective media within 90
30 * days of receipt.
d672fcab 31 *
e53c9681 32 * Unicode, Inc. hereby grants the right to freely use the information
33 * supplied in this file in the creation of products supporting the
34 * Unicode Standard, and to make copies of this file in any form for
35 * internal or external distribution as long as this notice remains
36 * attached.
31841a9e 37 *
38 * @version $Id$
d6c32258 39 * @package squirrelmail
40 * @subpackage decode
41 */
42
43/**
44 * Decode iso8859-7 encoded strings
45 * @param string $string Encoded string
46 * @return string $string Decoded string
d672fcab 47 */
df8c4d6d 48function charset_decode_iso_8859_7 ($string) {
d672fcab 49 global $default_charset;
50
51 if (strtolower($default_charset) == 'iso-8859-7')
52 return $string;
53
e53c9681 54 // don't do decoding when there are no 8bit symbols
55 if (! sq_is8bit($string,'iso-8859-7'))
d672fcab 56 return $string;
57
58 $iso8859_7 = array(
e53c9681 59 "\xA0" => '&#160;',
60 "\xA1" => '&#8216;',
61 "\xA2" => '&#8217;',
62 "\xA3" => '&#163;',
63 "\xA6" => '&#166;',
64 "\xA7" => '&#167;',
65 "\xA8" => '&#168;',
66 "\xA9" => '&#169;',
67 "\xAB" => '&#171;',
68 "\xAC" => '&#172;',
69 "\xAD" => '&#173;',
70 "\xAF" => '&#8213;',
71 "\xB0" => '&#176;',
72 "\xB1" => '&#177;',
73 "\xB2" => '&#178;',
74 "\xB3" => '&#179;',
75 "\xB4" => '&#900;',
76 "\xB5" => '&#901;',
77 "\xB6" => '&#902;',
78 "\xB7" => '&#183;',
79 "\xB8" => '&#904;',
80 "\xB9" => '&#905;',
81 "\xBA" => '&#906;',
82 "\xBB" => '&#187;',
83 "\xBC" => '&#908;',
84 "\xBD" => '&#189;',
85 "\xBE" => '&#910;',
86 "\xBF" => '&#911;',
87 "\xC0" => '&#912;',
88 "\xC1" => '&#913;',
89 "\xC2" => '&#914;',
90 "\xC3" => '&#915;',
91 "\xC4" => '&#916;',
92 "\xC5" => '&#917;',
93 "\xC6" => '&#918;',
94 "\xC7" => '&#919;',
95 "\xC8" => '&#920;',
96 "\xC9" => '&#921;',
97 "\xCA" => '&#922;',
98 "\xCB" => '&#923;',
99 "\xCC" => '&#924;',
100 "\xCD" => '&#925;',
101 "\xCE" => '&#926;',
102 "\xCF" => '&#927;',
103 "\xD0" => '&#928;',
104 "\xD1" => '&#929;',
105 "\xD3" => '&#931;',
106 "\xD4" => '&#932;',
107 "\xD5" => '&#933;',
108 "\xD6" => '&#934;',
109 "\xD7" => '&#935;',
110 "\xD8" => '&#936;',
111 "\xD9" => '&#937;',
112 "\xDA" => '&#938;',
113 "\xDB" => '&#939;',
114 "\xDC" => '&#940;',
115 "\xDD" => '&#941;',
116 "\xDE" => '&#942;',
117 "\xDF" => '&#943;',
118 "\xE0" => '&#944;',
119 "\xE1" => '&#945;',
120 "\xE2" => '&#946;',
121 "\xE3" => '&#947;',
122 "\xE4" => '&#948;',
123 "\xE5" => '&#949;',
124 "\xE6" => '&#950;',
125 "\xE7" => '&#951;',
126 "\xE8" => '&#952;',
127 "\xE9" => '&#953;',
128 "\xEA" => '&#954;',
129 "\xEB" => '&#955;',
130 "\xEC" => '&#956;',
131 "\xED" => '&#957;',
132 "\xEE" => '&#958;',
133 "\xEF" => '&#959;',
134 "\xF0" => '&#960;',
135 "\xF1" => '&#961;',
136 "\xF2" => '&#962;',
137 "\xF3" => '&#963;',
138 "\xF4" => '&#964;',
139 "\xF5" => '&#965;',
140 "\xF6" => '&#966;',
141 "\xF7" => '&#967;',
142 "\xF8" => '&#968;',
143 "\xF9" => '&#969;',
144 "\xFA" => '&#970;',
145 "\xFB" => '&#971;',
146 "\xFC" => '&#972;',
147 "\xFD" => '&#973;',
148 "\xFE" => '&#974;'
d672fcab 149 );
150
151 $string = str_replace(array_keys($iso8859_7), array_values($iso8859_7), $string);
152
153 return $string;
154}
e53c9681 155?>