| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * decode/iso8859-13.php |
| 5 | * |
| 6 | * This file contains iso-8859-13 decoding function that is needed to read |
| 7 | * iso-8859-13 encoded mails in non-iso-8859-13 locale. |
| 8 | * |
| 9 | * Original data taken from: |
| 10 | * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-13.TXT |
| 11 | * |
| 12 | * Name: ISO/IEC 8859-13:1998 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-2010 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-13 |
| 45 | * @param string $string Encoded string |
| 46 | * @return string $string Decoded string |
| 47 | */ |
| 48 | function charset_decode_iso_8859_13 ($string) { |
| 49 | // don't do decoding when there are no 8bit symbols |
| 50 | if (! sq_is8bit($string,'iso-8859-13')) |
| 51 | return $string; |
| 52 | |
| 53 | $iso8859_13 = array( |
| 54 | "\xA0" => ' ', |
| 55 | "\xA1" => '”', |
| 56 | "\xA2" => '¢', |
| 57 | "\xA3" => '£', |
| 58 | "\xA4" => '¤', |
| 59 | "\xA5" => '„', |
| 60 | "\xA6" => '¦', |
| 61 | "\xA7" => '§', |
| 62 | "\xA8" => 'Ø', |
| 63 | "\xA9" => '©', |
| 64 | "\xAA" => 'Ŗ', |
| 65 | "\xAB" => '«', |
| 66 | "\xAC" => '¬', |
| 67 | "\xAD" => '­', |
| 68 | "\xAE" => '®', |
| 69 | "\xAF" => 'Æ', |
| 70 | "\xB0" => '°', |
| 71 | "\xB1" => '±', |
| 72 | "\xB2" => '²', |
| 73 | "\xB3" => '³', |
| 74 | "\xB4" => '“', |
| 75 | "\xB5" => 'µ', |
| 76 | "\xB6" => '¶', |
| 77 | "\xB7" => '·', |
| 78 | "\xB8" => 'ø', |
| 79 | "\xB9" => '¹', |
| 80 | "\xBA" => 'ŗ', |
| 81 | "\xBB" => '»', |
| 82 | "\xBC" => '¼', |
| 83 | "\xBD" => '½', |
| 84 | "\xBE" => '¾', |
| 85 | "\xBF" => 'æ', |
| 86 | "\xC0" => 'Ą', |
| 87 | "\xC1" => 'Į', |
| 88 | "\xC2" => 'Ā', |
| 89 | "\xC3" => 'Ć', |
| 90 | "\xC4" => 'Ä', |
| 91 | "\xC5" => 'Å', |
| 92 | "\xC6" => 'Ę', |
| 93 | "\xC7" => 'Ē', |
| 94 | "\xC8" => 'Č', |
| 95 | "\xC9" => 'É', |
| 96 | "\xCA" => 'Ź', |
| 97 | "\xCB" => 'Ė', |
| 98 | "\xCC" => 'Ģ', |
| 99 | "\xCD" => 'Ķ', |
| 100 | "\xCE" => 'Ī', |
| 101 | "\xCF" => 'Ļ', |
| 102 | "\xD0" => 'Š', |
| 103 | "\xD1" => 'Ń', |
| 104 | "\xD2" => 'Ņ', |
| 105 | "\xD3" => 'Ó', |
| 106 | "\xD4" => 'Ō', |
| 107 | "\xD5" => 'Õ', |
| 108 | "\xD6" => 'Ö', |
| 109 | "\xD7" => '×', |
| 110 | "\xD8" => 'Ų', |
| 111 | "\xD9" => 'Ł', |
| 112 | "\xDA" => 'Ś', |
| 113 | "\xDB" => 'Ū', |
| 114 | "\xDC" => 'Ü', |
| 115 | "\xDD" => 'Ż', |
| 116 | "\xDE" => 'Ž', |
| 117 | "\xDF" => 'ß', |
| 118 | "\xE0" => 'ą', |
| 119 | "\xE1" => 'į', |
| 120 | "\xE2" => 'ā', |
| 121 | "\xE3" => 'ć', |
| 122 | "\xE4" => 'ä', |
| 123 | "\xE5" => 'å', |
| 124 | "\xE6" => 'ę', |
| 125 | "\xE7" => 'ē', |
| 126 | "\xE8" => 'č', |
| 127 | "\xE9" => 'é', |
| 128 | "\xEA" => 'ź', |
| 129 | "\xEB" => 'ė', |
| 130 | "\xEC" => 'ģ', |
| 131 | "\xED" => 'ķ', |
| 132 | "\xEE" => 'ī', |
| 133 | "\xEF" => 'ļ', |
| 134 | "\xF0" => 'š', |
| 135 | "\xF1" => 'ń', |
| 136 | "\xF2" => 'ņ', |
| 137 | "\xF3" => 'ó', |
| 138 | "\xF4" => 'ō', |
| 139 | "\xF5" => 'õ', |
| 140 | "\xF6" => 'ö', |
| 141 | "\xF7" => '÷', |
| 142 | "\xF8" => 'ų', |
| 143 | "\xF9" => 'ł', |
| 144 | "\xFA" => 'ś', |
| 145 | "\xFB" => 'ū', |
| 146 | "\xFC" => 'ü', |
| 147 | "\xFD" => 'ż', |
| 148 | "\xFE" => 'ž', |
| 149 | "\xFF" => '’' |
| 150 | ); |
| 151 | |
| 152 | $string = str_replace(array_keys($iso8859_13), array_values($iso8859_13), $string); |
| 153 | |
| 154 | return $string; |
| 155 | } |