Makes managing decoding easier. Mac decoding moved to separate cvs module
[squirrelmail.git] / functions / decode / iso_8859_3.php
CommitLineData
d672fcab 1<?php
d6c32258 2/**
d672fcab 3 * decode/iso8859-3.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 iso-8859-3 decoding function that is needed to read
10 * iso-8859-3 encoded mails in non-iso-8859-3 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-3.TXT
14 *
15 * Name: ISO/IEC 8859-3:1999 to Unicode
16 * Unicode version: 3.0
17 * Table version: 1.0
18 * Table format: Format A
19 * Date: 1999 July 27
20 * Authors: Ken Whistler <kenw@sybase.com>
21 *
22 * Original copyright:
23 * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
24 *
25 * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
26 * No claims are made as to fitness for any particular purpose. No
27 * warranties of any kind are expressed or implied. The recipient
28 * agrees to determine applicability of information provided. If this
29 * file has been provided on optical media by Unicode, Inc., the sole
30 * remedy for any claim will be exchange of defective media within 90
31 * days of receipt.
32 *
33 * Unicode, Inc. hereby grants the right to freely use the information
34 * supplied in this file in the creation of products supporting the
35 * Unicode Standard, and to make copies of this file in any form for
36 * internal or external distribution as long as this notice remains
37 * attached.
d6c32258 38 * @package squirrelmail
39 * @subpackage decode
40 */
41
42/**
43 * Decode iso8859-3 encoded string
44 * @param string $string Encoded string
45 * @return string $string Decoded string
d672fcab 46 */
df8c4d6d 47function charset_decode_iso_8859_3 ($string) {
d672fcab 48 global $default_charset;
49
50 if (strtolower($default_charset) == 'iso-8859-3')
51 return $string;
52
53 /* Only do the slow convert if there are 8-bit characters */
54 /* there is no 0x80-0x9F letters in ISO8859-* */
55 if ( ! ereg("[\241-\377]", $string) )
56 return $string;
57
58 $iso8859_3 = array(
59 "\xA0" => '&#160;',
60 "\xA1" => '&#294;',
61 "\xA2" => '&#728;',
62 "\xA3" => '&#163;',
63 "\xA4" => '&#164;',
64 "\xA6" => '&#292;',
65 "\xA7" => '&#167;',
66 "\xA8" => '&#168;',
67 "\xA9" => '&#304;',
68 "\xAA" => '&#350;',
69 "\xAB" => '&#286;',
70 "\xAC" => '&#308;',
71 "\xAD" => '&#173;',
72 "\xAF" => '&#379;',
73 "\xB0" => '&#176;',
74 "\xB1" => '&#295;',
75 "\xB2" => '&#178;',
76 "\xB3" => '&#179;',
77 "\xB4" => '&#180;',
78 "\xB5" => '&#181;',
79 "\xB6" => '&#293;',
80 "\xB7" => '&#183;',
81 "\xB8" => '&#184;',
82 "\xB9" => '&#305;',
83 "\xBA" => '&#351;',
84 "\xBB" => '&#287;',
85 "\xBC" => '&#309;',
86 "\xBD" => '&#189;',
87 "\xBF" => '&#380;',
88 "\xC0" => '&#192;',
89 "\xC1" => '&#193;',
90 "\xC2" => '&#194;',
91 "\xC4" => '&#196;',
92 "\xC5" => '&#266;',
93 "\xC6" => '&#264;',
94 "\xC7" => '&#199;',
95 "\xC8" => '&#200;',
96 "\xC9" => '&#201;',
97 "\xCA" => '&#202;',
98 "\xCB" => '&#203;',
99 "\xCC" => '&#204;',
100 "\xCD" => '&#205;',
101 "\xCE" => '&#206;',
102 "\xCF" => '&#207;',
103 "\xD1" => '&#209;',
104 "\xD2" => '&#210;',
105 "\xD3" => '&#211;',
106 "\xD4" => '&#212;',
107 "\xD5" => '&#288;',
108 "\xD6" => '&#214;',
109 "\xD7" => '&#215;',
110 "\xD8" => '&#284;',
111 "\xD9" => '&#217;',
112 "\xDA" => '&#218;',
113 "\xDB" => '&#219;',
114 "\xDC" => '&#220;',
115 "\xDD" => '&#364;',
116 "\xDE" => '&#348;',
117 "\xDF" => '&#223;',
118 "\xE0" => '&#224;',
119 "\xE1" => '&#225;',
120 "\xE2" => '&#226;',
121 "\xE4" => '&#228;',
122 "\xE5" => '&#267;',
123 "\xE6" => '&#265;',
124 "\xE7" => '&#231;',
125 "\xE8" => '&#232;',
126 "\xE9" => '&#233;',
127 "\xEA" => '&#234;',
128 "\xEB" => '&#235;',
129 "\xEC" => '&#236;',
130 "\xED" => '&#237;',
131 "\xEE" => '&#238;',
132 "\xEF" => '&#239;',
133 "\xF1" => '&#241;',
134 "\xF2" => '&#242;',
135 "\xF3" => '&#243;',
136 "\xF4" => '&#244;',
137 "\xF5" => '&#289;',
138 "\xF6" => '&#246;',
139 "\xF7" => '&#247;',
140 "\xF8" => '&#285;',
141 "\xF9" => '&#249;',
142 "\xFA" => '&#250;',
143 "\xFB" => '&#251;',
144 "\xFC" => '&#252;',
145 "\xFD" => '&#365;',
146 "\xFE" => '&#349;',
147 "\xFF" => '&#729;'
148 );
149
150 $string = str_replace(array_keys($iso8859_3), array_values($iso8859_3), $string);
151
152 return $string;
153}
154
d6c32258 155?>