d672fcab |
1 | <?php |
2 | /* |
3 | * decode/iso8859-6.php |
4 | * $Id$ |
5 | * |
6 | * Copyright (c) 1999-2003 The SquirrelMail Project Team |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file contains iso-8859-6 decoding function that is needed to read |
10 | * iso-8859-6 encoded mails in non-iso-8859-6 locale. |
11 | * |
12 | * Original data taken from: |
13 | * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-6.TXT |
14 | * |
15 | * Name: ISO 8859-6: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. |
38 | * |
39 | */ |
40 | function charset_decode_iso8859_6 ($string) { |
41 | global $default_charset; |
42 | |
43 | if (strtolower($default_charset) == 'iso-8859-6') |
44 | return $string; |
45 | |
46 | /* Only do the slow convert if there are 8-bit characters */ |
47 | /* there is no 0x80-0x9F letters in ISO8859-* */ |
48 | if ( ! ereg("[\241-\377]", $string) ) |
49 | return $string; |
50 | |
51 | $iso8859_6 = array( |
52 | "\xA0" => ' ', |
53 | "\xA4" => '¤', |
54 | "\xAC" => '،', |
55 | "\xAD" => '­', |
56 | "\xBB" => '؛', |
57 | "\xBF" => '؟', |
58 | "\xC1" => 'ء', |
59 | "\xC2" => 'آ', |
60 | "\xC3" => 'أ', |
61 | "\xC4" => 'ؤ', |
62 | "\xC5" => 'إ', |
63 | "\xC6" => 'ئ', |
64 | "\xC7" => 'ا', |
65 | "\xC8" => 'ب', |
66 | "\xC9" => 'ة', |
67 | "\xCA" => 'ت', |
68 | "\xCB" => 'ث', |
69 | "\xCC" => 'ج', |
70 | "\xCD" => 'ح', |
71 | "\xCE" => 'خ', |
72 | "\xCF" => 'د', |
73 | "\xD0" => 'ذ', |
74 | "\xD1" => 'ر', |
75 | "\xD2" => 'ز', |
76 | "\xD3" => 'س', |
77 | "\xD4" => 'ش', |
78 | "\xD5" => 'ص', |
79 | "\xD6" => 'ض', |
80 | "\xD7" => 'ط', |
81 | "\xD8" => 'ظ', |
82 | "\xD9" => 'ع', |
83 | "\xDA" => 'غ', |
84 | "\xE0" => 'ـ', |
85 | "\xE1" => 'ف', |
86 | "\xE2" => 'ق', |
87 | "\xE3" => 'ك', |
88 | "\xE4" => 'ل', |
89 | "\xE5" => 'م', |
90 | "\xE6" => 'ن', |
91 | "\xE7" => 'ه', |
92 | "\xE8" => 'و', |
93 | "\xE9" => 'ى', |
94 | "\xEA" => 'ي', |
95 | "\xEB" => 'ً', |
96 | "\xEC" => 'ٌ', |
97 | "\xED" => 'ٍ', |
98 | "\xEE" => 'َ', |
99 | "\xEF" => 'ُ', |
100 | "\xF0" => 'ِ', |
101 | "\xF1" => 'ّ', |
102 | "\xF2" => 'ْ' |
103 | ); |
104 | |
105 | $string = str_replace(array_keys(iso8859_6), array_values($iso8859_6), $string); |
106 | |
107 | return $string; |
108 | } |
109 | |
110 | ?> |