adding sq_is8bit and sq_mb_list_encodings functions.
[squirrelmail.git] / functions / decode / iso_8859_3.php
... / ...
CommitLineData
1<?php
2/**
3 * decode/iso8859-3.php
4 *
5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This file contains iso-8859-3 decoding function that is needed to read
9 * iso-8859-3 encoded mails in non-iso-8859-3 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-3.TXT
13 *
14 * Name: ISO/IEC 8859-3:1999 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:
22 * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
23 *
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.
31 *
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.
37 *
38 * @version $Id$
39 * @package squirrelmail
40 * @subpackage decode
41 */
42
43/**
44 * Decode iso8859-3 encoded string
45 * @param string $string Encoded string
46 * @return string $string Decoded string
47 */
48function charset_decode_iso_8859_3 ($string) {
49 global $default_charset;
50
51 if (strtolower($default_charset) == 'iso-8859-3')
52 return $string;
53
54 /* Only do the slow convert if there are 8-bit characters */
55 /* there is no 0x80-0x9F letters in ISO8859-* */
56 if ( ! ereg("[\241-\377]", $string) )
57 return $string;
58
59 $iso8859_3 = array(
60 "\xA0" => '&#160;',
61 "\xA1" => '&#294;',
62 "\xA2" => '&#728;',
63 "\xA3" => '&#163;',
64 "\xA4" => '&#164;',
65 "\xA6" => '&#292;',
66 "\xA7" => '&#167;',
67 "\xA8" => '&#168;',
68 "\xA9" => '&#304;',
69 "\xAA" => '&#350;',
70 "\xAB" => '&#286;',
71 "\xAC" => '&#308;',
72 "\xAD" => '&#173;',
73 "\xAF" => '&#379;',
74 "\xB0" => '&#176;',
75 "\xB1" => '&#295;',
76 "\xB2" => '&#178;',
77 "\xB3" => '&#179;',
78 "\xB4" => '&#180;',
79 "\xB5" => '&#181;',
80 "\xB6" => '&#293;',
81 "\xB7" => '&#183;',
82 "\xB8" => '&#184;',
83 "\xB9" => '&#305;',
84 "\xBA" => '&#351;',
85 "\xBB" => '&#287;',
86 "\xBC" => '&#309;',
87 "\xBD" => '&#189;',
88 "\xBF" => '&#380;',
89 "\xC0" => '&#192;',
90 "\xC1" => '&#193;',
91 "\xC2" => '&#194;',
92 "\xC4" => '&#196;',
93 "\xC5" => '&#266;',
94 "\xC6" => '&#264;',
95 "\xC7" => '&#199;',
96 "\xC8" => '&#200;',
97 "\xC9" => '&#201;',
98 "\xCA" => '&#202;',
99 "\xCB" => '&#203;',
100 "\xCC" => '&#204;',
101 "\xCD" => '&#205;',
102 "\xCE" => '&#206;',
103 "\xCF" => '&#207;',
104 "\xD1" => '&#209;',
105 "\xD2" => '&#210;',
106 "\xD3" => '&#211;',
107 "\xD4" => '&#212;',
108 "\xD5" => '&#288;',
109 "\xD6" => '&#214;',
110 "\xD7" => '&#215;',
111 "\xD8" => '&#284;',
112 "\xD9" => '&#217;',
113 "\xDA" => '&#218;',
114 "\xDB" => '&#219;',
115 "\xDC" => '&#220;',
116 "\xDD" => '&#364;',
117 "\xDE" => '&#348;',
118 "\xDF" => '&#223;',
119 "\xE0" => '&#224;',
120 "\xE1" => '&#225;',
121 "\xE2" => '&#226;',
122 "\xE4" => '&#228;',
123 "\xE5" => '&#267;',
124 "\xE6" => '&#265;',
125 "\xE7" => '&#231;',
126 "\xE8" => '&#232;',
127 "\xE9" => '&#233;',
128 "\xEA" => '&#234;',
129 "\xEB" => '&#235;',
130 "\xEC" => '&#236;',
131 "\xED" => '&#237;',
132 "\xEE" => '&#238;',
133 "\xEF" => '&#239;',
134 "\xF1" => '&#241;',
135 "\xF2" => '&#242;',
136 "\xF3" => '&#243;',
137 "\xF4" => '&#244;',
138 "\xF5" => '&#289;',
139 "\xF6" => '&#246;',
140 "\xF7" => '&#247;',
141 "\xF8" => '&#285;',
142 "\xF9" => '&#249;',
143 "\xFA" => '&#250;',
144 "\xFB" => '&#251;',
145 "\xFC" => '&#252;',
146 "\xFD" => '&#365;',
147 "\xFE" => '&#349;',
148 "\xFF" => '&#729;'
149 );
150
151 $string = str_replace(array_keys($iso8859_3), array_values($iso8859_3), $string);
152
153 return $string;
154}
155
156?>