| 1 | <?php |
| 2 | /** |
| 3 | * decode/iso-ir-111.php |
| 4 | * $Id$ |
| 5 | * |
| 6 | * Copyright (c) 2003-2004 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * This file contains iso-ir-111 decoding function that is needed to read |
| 10 | * iso-ir-111 encoded mails in non-iso-ir-111 locale. |
| 11 | * |
| 12 | * Original data taken from: |
| 13 | * http://crl.nmsu.edu/~mleisher/csets/ISOIR111.TXT |
| 14 | * |
| 15 | * Original ID: Id: ISOIR111.TXT,v 1.2 1999/08/23 18:34:15 mleisher Exp |
| 16 | * Name: ISO IR 111/ECMA Cyrillic to Unicode 2.1 mapping table. |
| 17 | * Typed in by hand from |
| 18 | * http://www.fingertipsoft.com/ref/cyrillic/charsets.html |
| 19 | * Author: Mark Leisher <mleisher@crl.nmsu.edu> |
| 20 | * Date: 05 March 1998 |
| 21 | * |
| 22 | * Original copyright: |
| 23 | * Copyright 1999 Computing Research Labs, New Mexico State University |
| 24 | * |
| 25 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 26 | * copy of this software and associated documentation files (the ""Software""), |
| 27 | * to deal in the Software without restriction, including without limitation |
| 28 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 29 | * and/or sell copies of the Software, and to permit persons to whom the |
| 30 | * Software is furnished to do so, subject to the following conditions: |
| 31 | * |
| 32 | * The above copyright notice and this permission notice shall be included in |
| 33 | * all copies or substantial portions of the Software. |
| 34 | * |
| 35 | * THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 36 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 37 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 38 | * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY |
| 39 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT |
| 40 | * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR |
| 41 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 42 | * |
| 43 | * @package squirrelmail |
| 44 | * @subpackage decode |
| 45 | */ |
| 46 | |
| 47 | /** |
| 48 | * Decode iso-ir-111 encoded strings |
| 49 | * @param string $string Encoded string |
| 50 | * @return string Decoded string |
| 51 | */ |
| 52 | function charset_decode_iso_ir_111 ($string) { |
| 53 | global $default_charset; |
| 54 | |
| 55 | if (strtolower($default_charset) == 'iso-ir-111') |
| 56 | return $string; |
| 57 | |
| 58 | /* Only do the slow convert if there are 8-bit characters */ |
| 59 | /* there is no 0x80-0x9F letters in ISO-IR-111 */ |
| 60 | if ( ! ereg("[\241-\377]", $string) ) |
| 61 | return $string; |
| 62 | |
| 63 | $iso_ir_111 = array( |
| 64 | "\xA0" => ' ', |
| 65 | "\xA1" => 'ђ', |
| 66 | "\xA2" => 'ѓ', |
| 67 | "\xA3" => 'ё', |
| 68 | "\xA4" => 'є', |
| 69 | "\xA5" => 'ѕ', |
| 70 | "\xA6" => 'і', |
| 71 | "\xA7" => 'ї', |
| 72 | "\xA8" => 'ј', |
| 73 | "\xA9" => 'љ', |
| 74 | "\xAA" => 'њ', |
| 75 | "\xAB" => 'ћ', |
| 76 | "\xAC" => 'ќ', |
| 77 | "\xAD" => '­', |
| 78 | "\xAE" => 'ў', |
| 79 | "\xAF" => 'џ', |
| 80 | "\xB0" => '№', |
| 81 | "\xB1" => 'Ђ', |
| 82 | "\xB2" => 'Ѓ', |
| 83 | "\xB3" => 'Ё', |
| 84 | "\xB4" => 'Є', |
| 85 | "\xB5" => 'Ѕ', |
| 86 | "\xB6" => 'І', |
| 87 | "\xB7" => 'Ї', |
| 88 | "\xB8" => 'Ј', |
| 89 | "\xB9" => 'Љ', |
| 90 | "\xBA" => 'Њ', |
| 91 | "\xBB" => 'Ћ', |
| 92 | "\xBC" => 'Ќ', |
| 93 | "\xBD" => '¤', |
| 94 | "\xBE" => 'Ў', |
| 95 | "\xBF" => 'Џ', |
| 96 | "\xC0" => 'ю', |
| 97 | "\xC1" => 'а', |
| 98 | "\xC2" => 'б', |
| 99 | "\xC3" => 'ц', |
| 100 | "\xC4" => 'д', |
| 101 | "\xC5" => 'е', |
| 102 | "\xC6" => 'ф', |
| 103 | "\xC7" => 'г', |
| 104 | "\xC8" => 'х', |
| 105 | "\xC9" => 'и', |
| 106 | "\xCA" => 'й', |
| 107 | "\xCB" => 'к', |
| 108 | "\xCC" => 'л', |
| 109 | "\xCD" => 'м', |
| 110 | "\xCE" => 'н', |
| 111 | "\xCF" => 'о', |
| 112 | "\xD0" => 'п', |
| 113 | "\xD1" => 'я', |
| 114 | "\xD2" => 'р', |
| 115 | "\xD3" => 'с', |
| 116 | "\xD4" => 'т', |
| 117 | "\xD5" => 'у', |
| 118 | "\xD6" => 'ж', |
| 119 | "\xD7" => 'в', |
| 120 | "\xD8" => 'ь', |
| 121 | "\xD9" => 'ы', |
| 122 | "\xDA" => 'з', |
| 123 | "\xDB" => 'ш', |
| 124 | "\xDC" => 'э', |
| 125 | "\xDD" => 'щ', |
| 126 | "\xDE" => 'ч', |
| 127 | "\xDF" => 'ъ', |
| 128 | "\xE0" => 'Ю', |
| 129 | "\xE1" => 'А', |
| 130 | "\xE2" => 'Б', |
| 131 | "\xE3" => 'Ц', |
| 132 | "\xE4" => 'Д', |
| 133 | "\xE5" => 'Е', |
| 134 | "\xE6" => 'Ф', |
| 135 | "\xE7" => 'Г', |
| 136 | "\xE8" => 'Х', |
| 137 | "\xE9" => 'И', |
| 138 | "\xEA" => 'Й', |
| 139 | "\xEB" => 'К', |
| 140 | "\xEC" => 'Л', |
| 141 | "\xED" => 'М', |
| 142 | "\xEE" => 'Н', |
| 143 | "\xEF" => 'О', |
| 144 | "\xF0" => 'П', |
| 145 | "\xF1" => 'Я', |
| 146 | "\xF2" => 'Р', |
| 147 | "\xF3" => 'С', |
| 148 | "\xF4" => 'Т', |
| 149 | "\xF5" => 'У', |
| 150 | "\xF6" => 'Ж', |
| 151 | "\xF7" => 'В', |
| 152 | "\xF8" => 'Ь', |
| 153 | "\xF9" => 'Ы', |
| 154 | "\xFA" => 'З', |
| 155 | "\xFB" => 'Ш', |
| 156 | "\xFC" => 'Э', |
| 157 | "\xFD" => 'Щ', |
| 158 | "\xFE" => 'Ч', |
| 159 | "\xFF" => 'Ъ' |
| 160 | ); |
| 161 | |
| 162 | $string = str_replace(array_keys($iso_ir_111), array_values($iso_ir_111), $string); |
| 163 | |
| 164 | return $string; |
| 165 | } |
| 166 | |
| 167 | ?> |