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

« back to all changes in this revision

Viewing changes to functions/decode/iso_8859_6.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/iso8859-6.php
 
4
 * $Id: iso_8859_6.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-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
 * @package squirrelmail
 
39
 * @subpackage decode
 
40
 */
 
41
 
 
42
/**
 
43
 * Decode iso8859-6 strings
 
44
 * @param string $string Encoded string
 
45
 * @return string $string Decoded string
 
46
 */
 
47
function charset_decode_iso_8859_6 ($string) {
 
48
    global $default_charset;
 
49
 
 
50
    if (strtolower($default_charset) == 'iso-8859-6')
 
51
        return $string;
 
52
 
 
53
    /* Only do the slow convert if there are 8-bit characters */
 
54
    /* there is no 0x80-0x9F letters in ISO8859-* */
 
55
    if ( ! ereg("[\241-\377]", $string) )
 
56
        return $string;
 
57
 
 
58
    $iso8859_6 = array(
 
59
        "\xA0" => '&#160;',
 
60
        "\xA4" => '&#164;',
 
61
        "\xAC" => '&#1548;',
 
62
        "\xAD" => '&#173;',
 
63
        "\xBB" => '&#1563;',
 
64
        "\xBF" => '&#1567;',
 
65
        "\xC1" => '&#1569;',
 
66
        "\xC2" => '&#1570;',
 
67
        "\xC3" => '&#1571;',
 
68
        "\xC4" => '&#1572;',
 
69
        "\xC5" => '&#1573;',
 
70
        "\xC6" => '&#1574;',
 
71
        "\xC7" => '&#1575;',
 
72
        "\xC8" => '&#1576;',
 
73
        "\xC9" => '&#1577;',
 
74
        "\xCA" => '&#1578;',
 
75
        "\xCB" => '&#1579;',
 
76
        "\xCC" => '&#1580;',
 
77
        "\xCD" => '&#1581;',
 
78
        "\xCE" => '&#1582;',
 
79
        "\xCF" => '&#1583;',
 
80
        "\xD0" => '&#1584;',
 
81
        "\xD1" => '&#1585;',
 
82
        "\xD2" => '&#1586;',
 
83
        "\xD3" => '&#1587;',
 
84
        "\xD4" => '&#1588;',
 
85
        "\xD5" => '&#1589;',
 
86
        "\xD6" => '&#1590;',
 
87
        "\xD7" => '&#1591;',
 
88
        "\xD8" => '&#1592;',
 
89
        "\xD9" => '&#1593;',
 
90
        "\xDA" => '&#1594;',
 
91
        "\xE0" => '&#1600;',
 
92
        "\xE1" => '&#1601;',
 
93
        "\xE2" => '&#1602;',
 
94
        "\xE3" => '&#1603;',
 
95
        "\xE4" => '&#1604;',
 
96
        "\xE5" => '&#1605;',
 
97
        "\xE6" => '&#1606;',
 
98
        "\xE7" => '&#1607;',
 
99
        "\xE8" => '&#1608;',
 
100
        "\xE9" => '&#1609;',
 
101
        "\xEA" => '&#1610;',
 
102
        "\xEB" => '&#1611;',
 
103
        "\xEC" => '&#1612;',
 
104
        "\xED" => '&#1613;',
 
105
        "\xEE" => '&#1614;',
 
106
        "\xEF" => '&#1615;',
 
107
        "\xF0" => '&#1616;',
 
108
        "\xF1" => '&#1617;',
 
109
        "\xF2" => '&#1618;'
 
110
    );
 
111
 
 
112
    $string = str_replace(array_keys($iso8859_6), array_values($iso8859_6), $string);
 
113
 
 
114
    return $string;
 
115
}
 
116
 
 
117
?>