~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to functions/decode/iso_ir_111.php

  • Committer: Bazaar Package Importer
  • Author(s): Sam Johnston
  • Date: 2004-02-04 01:42:12 UTC
  • Revision ID: james.westby@ubuntu.com-20040204014212-ek9533qvd2vo1wa1
Tags: upstream-1.5.0
ImportĀ upstreamĀ versionĀ 1.5.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * decode/iso-ir-111.php
 
4
 * $Id: iso_ir_111.php,v 1.1 2003/12/21 11:40:08 tokul Exp $
 
5
 *
 
6
 * Copyright (c) 2003 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" => '&#160;',
 
65
        "\xA1" => '&#1106;',
 
66
        "\xA2" => '&#1107;',
 
67
        "\xA3" => '&#1105;',
 
68
        "\xA4" => '&#1108;',
 
69
        "\xA5" => '&#1109;',
 
70
        "\xA6" => '&#1110;',
 
71
        "\xA7" => '&#1111;',
 
72
        "\xA8" => '&#1112;',
 
73
        "\xA9" => '&#1113;',
 
74
        "\xAA" => '&#1114;',
 
75
        "\xAB" => '&#1115;',
 
76
        "\xAC" => '&#1116;',
 
77
        "\xAD" => '&#173;',
 
78
        "\xAE" => '&#1118;',
 
79
        "\xAF" => '&#1119;',
 
80
        "\xB0" => '&#8470;',
 
81
        "\xB1" => '&#1026;',
 
82
        "\xB2" => '&#1027;',
 
83
        "\xB3" => '&#1025;',
 
84
        "\xB4" => '&#1028;',
 
85
        "\xB5" => '&#1029;',
 
86
        "\xB6" => '&#1030;',
 
87
        "\xB7" => '&#1031;',
 
88
        "\xB8" => '&#1032;',
 
89
        "\xB9" => '&#1033;',
 
90
        "\xBA" => '&#1034;',
 
91
        "\xBB" => '&#1035;',
 
92
        "\xBC" => '&#1036;',
 
93
        "\xBD" => '&#164;',
 
94
        "\xBE" => '&#1038;',
 
95
        "\xBF" => '&#1039;',
 
96
        "\xC0" => '&#1102;',
 
97
        "\xC1" => '&#1072;',
 
98
        "\xC2" => '&#1073;',
 
99
        "\xC3" => '&#1094;',
 
100
        "\xC4" => '&#1076;',
 
101
        "\xC5" => '&#1077;',
 
102
        "\xC6" => '&#1092;',
 
103
        "\xC7" => '&#1075;',
 
104
        "\xC8" => '&#1093;',
 
105
        "\xC9" => '&#1080;',
 
106
        "\xCA" => '&#1081;',
 
107
        "\xCB" => '&#1082;',
 
108
        "\xCC" => '&#1083;',
 
109
        "\xCD" => '&#1084;',
 
110
        "\xCE" => '&#1085;',
 
111
        "\xCF" => '&#1086;',
 
112
        "\xD0" => '&#1087;',
 
113
        "\xD1" => '&#1103;',
 
114
        "\xD2" => '&#1088;',
 
115
        "\xD3" => '&#1089;',
 
116
        "\xD4" => '&#1090;',
 
117
        "\xD5" => '&#1091;',
 
118
        "\xD6" => '&#1078;',
 
119
        "\xD7" => '&#1074;',
 
120
        "\xD8" => '&#1100;',
 
121
        "\xD9" => '&#1099;',
 
122
        "\xDA" => '&#1079;',
 
123
        "\xDB" => '&#1096;',
 
124
        "\xDC" => '&#1101;',
 
125
        "\xDD" => '&#1097;',
 
126
        "\xDE" => '&#1095;',
 
127
        "\xDF" => '&#1098;',
 
128
        "\xE0" => '&#1070;',
 
129
        "\xE1" => '&#1040;',
 
130
        "\xE2" => '&#1041;',
 
131
        "\xE3" => '&#1062;',
 
132
        "\xE4" => '&#1044;',
 
133
        "\xE5" => '&#1045;',
 
134
        "\xE6" => '&#1060;',
 
135
        "\xE7" => '&#1043;',
 
136
        "\xE8" => '&#1061;',
 
137
        "\xE9" => '&#1048;',
 
138
        "\xEA" => '&#1049;',
 
139
        "\xEB" => '&#1050;',
 
140
        "\xEC" => '&#1051;',
 
141
        "\xED" => '&#1052;',
 
142
        "\xEE" => '&#1053;',
 
143
        "\xEF" => '&#1054;',
 
144
        "\xF0" => '&#1055;',
 
145
        "\xF1" => '&#1071;',
 
146
        "\xF2" => '&#1056;',
 
147
        "\xF3" => '&#1057;',
 
148
        "\xF4" => '&#1058;',
 
149
        "\xF5" => '&#1059;',
 
150
        "\xF6" => '&#1046;',
 
151
        "\xF7" => '&#1042;',
 
152
        "\xF8" => '&#1068;',
 
153
        "\xF9" => '&#1067;',
 
154
        "\xFA" => '&#1047;',
 
155
        "\xFB" => '&#1064;',
 
156
        "\xFC" => '&#1069;',
 
157
        "\xFD" => '&#1065;',
 
158
        "\xFE" => '&#1063;',
 
159
        "\xFF" => '&#1066;'
 
160
    );
 
161
 
 
162
    $string = str_replace(array_keys($iso_ir_111), array_values($iso_ir_111), $string);
 
163
 
 
164
    return $string;
 
165
}
 
166
 
 
167
?>