| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * decode/iso8859-7.php |
| 5 | * |
| 6 | * This file contains iso-8859-7 decoding function that is needed to read |
| 7 | * iso-8859-7 encoded mails in non-iso-8859-7 locale. |
| 8 | * |
| 9 | * Original data taken from: |
| 10 | * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-7.TXT |
| 11 | * |
| 12 | * Name: ISO 8859-7:1987 to Unicode |
| 13 | * Unicode version: 3.0 |
| 14 | * Table version: 1.0 |
| 15 | * Table format: Format A |
| 16 | * Date: 1999 July 27 |
| 17 | * Authors: Ken Whistler <kenw@sybase.com> |
| 18 | * |
| 19 | * Original copyright: |
| 20 | * Copyright (c) 1999 Unicode, Inc. All Rights reserved. |
| 21 | * |
| 22 | * This file is provided as-is by Unicode, Inc. (The Unicode Consortium). |
| 23 | * No claims are made as to fitness for any particular purpose. No |
| 24 | * warranties of any kind are expressed or implied. The recipient |
| 25 | * agrees to determine applicability of information provided. If this |
| 26 | * file has been provided on optical media by Unicode, Inc., the sole |
| 27 | * remedy for any claim will be exchange of defective media within 90 |
| 28 | * days of receipt. |
| 29 | * |
| 30 | * Unicode, Inc. hereby grants the right to freely use the information |
| 31 | * supplied in this file in the creation of products supporting the |
| 32 | * Unicode Standard, and to make copies of this file in any form for |
| 33 | * internal or external distribution as long as this notice remains |
| 34 | * attached. |
| 35 | * |
| 36 | * @copyright 2003-2009 The SquirrelMail Project Team |
| 37 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 38 | * @version $Id$ |
| 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 |
| 47 | */ |
| 48 | function charset_decode_iso_8859_7 ($string) { |
| 49 | // don't do decoding when there are no 8bit symbols |
| 50 | if (! sq_is8bit($string,'iso-8859-7')) |
| 51 | return $string; |
| 52 | |
| 53 | $iso8859_7 = array( |
| 54 | "\xA0" => ' ', |
| 55 | "\xA1" => '‘', |
| 56 | "\xA2" => '’', |
| 57 | "\xA3" => '£', |
| 58 | "\xA6" => '¦', |
| 59 | "\xA7" => '§', |
| 60 | "\xA8" => '¨', |
| 61 | "\xA9" => '©', |
| 62 | "\xAB" => '«', |
| 63 | "\xAC" => '¬', |
| 64 | "\xAD" => '­', |
| 65 | "\xAF" => '―', |
| 66 | "\xB0" => '°', |
| 67 | "\xB1" => '±', |
| 68 | "\xB2" => '²', |
| 69 | "\xB3" => '³', |
| 70 | "\xB4" => '΄', |
| 71 | "\xB5" => '΅', |
| 72 | "\xB6" => 'Ά', |
| 73 | "\xB7" => '·', |
| 74 | "\xB8" => 'Έ', |
| 75 | "\xB9" => 'Ή', |
| 76 | "\xBA" => 'Ί', |
| 77 | "\xBB" => '»', |
| 78 | "\xBC" => 'Ό', |
| 79 | "\xBD" => '½', |
| 80 | "\xBE" => 'Ύ', |
| 81 | "\xBF" => 'Ώ', |
| 82 | "\xC0" => 'ΐ', |
| 83 | "\xC1" => 'Α', |
| 84 | "\xC2" => 'Β', |
| 85 | "\xC3" => 'Γ', |
| 86 | "\xC4" => 'Δ', |
| 87 | "\xC5" => 'Ε', |
| 88 | "\xC6" => 'Ζ', |
| 89 | "\xC7" => 'Η', |
| 90 | "\xC8" => 'Θ', |
| 91 | "\xC9" => 'Ι', |
| 92 | "\xCA" => 'Κ', |
| 93 | "\xCB" => 'Λ', |
| 94 | "\xCC" => 'Μ', |
| 95 | "\xCD" => 'Ν', |
| 96 | "\xCE" => 'Ξ', |
| 97 | "\xCF" => 'Ο', |
| 98 | "\xD0" => 'Π', |
| 99 | "\xD1" => 'Ρ', |
| 100 | "\xD3" => 'Σ', |
| 101 | "\xD4" => 'Τ', |
| 102 | "\xD5" => 'Υ', |
| 103 | "\xD6" => 'Φ', |
| 104 | "\xD7" => 'Χ', |
| 105 | "\xD8" => 'Ψ', |
| 106 | "\xD9" => 'Ω', |
| 107 | "\xDA" => 'Ϊ', |
| 108 | "\xDB" => 'Ϋ', |
| 109 | "\xDC" => 'ά', |
| 110 | "\xDD" => 'έ', |
| 111 | "\xDE" => 'ή', |
| 112 | "\xDF" => 'ί', |
| 113 | "\xE0" => 'ΰ', |
| 114 | "\xE1" => 'α', |
| 115 | "\xE2" => 'β', |
| 116 | "\xE3" => 'γ', |
| 117 | "\xE4" => 'δ', |
| 118 | "\xE5" => 'ε', |
| 119 | "\xE6" => 'ζ', |
| 120 | "\xE7" => 'η', |
| 121 | "\xE8" => 'θ', |
| 122 | "\xE9" => 'ι', |
| 123 | "\xEA" => 'κ', |
| 124 | "\xEB" => 'λ', |
| 125 | "\xEC" => 'μ', |
| 126 | "\xED" => 'ν', |
| 127 | "\xEE" => 'ξ', |
| 128 | "\xEF" => 'ο', |
| 129 | "\xF0" => 'π', |
| 130 | "\xF1" => 'ρ', |
| 131 | "\xF2" => 'ς', |
| 132 | "\xF3" => 'σ', |
| 133 | "\xF4" => 'τ', |
| 134 | "\xF5" => 'υ', |
| 135 | "\xF6" => 'φ', |
| 136 | "\xF7" => 'χ', |
| 137 | "\xF8" => 'ψ', |
| 138 | "\xF9" => 'ω', |
| 139 | "\xFA" => 'ϊ', |
| 140 | "\xFB" => 'ϋ', |
| 141 | "\xFC" => 'ό', |
| 142 | "\xFD" => 'ύ', |
| 143 | "\xFE" => 'ώ' |
| 144 | ); |
| 145 | |
| 146 | $string = str_replace(array_keys($iso8859_7), array_values($iso8859_7), $string); |
| 147 | |
| 148 | return $string; |
| 149 | } |