1<?php
2/**
3 * functions/decode/x_mac_devanagari.php
4 * $Id: x_mac_devanagari.php 12467 2007-06-25 15:52:44Z kink $
5 *
6 * Copyright (c) 2003-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Original data taken from:
10 *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/APPLE/DEVANAGE.TXT
11 *
12 * Contents:
13 * Map (external version) from Mac OS Devanagari
14 * encoding to Unicode 2.1 through Unicode 3.2.
15 *
16 * Copyright:  (c) 1995-2002 by Apple Computer, Inc., all rights reserved.
17 *
18 * Contact:    charsets@apple.com
19 *
20 * Standard header:
21 * Apple, the Apple logo, and Macintosh are trademarks of Apple
22 * Computer, Inc., registered in the United States and other countries.
23 * Unicode is a trademark of Unicode Inc. For the sake of brevity,
24 * throughout this document, ""Macintosh"" can be used to refer to
25 * Macintosh computers and ""Unicode"" can be used to refer to the
26 * Unicode standard.
27 *
28 * Apple makes no warranty or representation, either express or
29 * implied, with respect to these tables, their quality, accuracy, or
30 * fitness for a particular purpose. In no event will Apple be liable
31 * for direct, indirect, special, incidental, or consequential damages
32 * resulting from any defect or inaccuracy in this document or the
33 * accompanying tables.
34 *
35 * These mapping tables and character lists are subject to change.
36 * The latest tables should be available from the following:
37 *
38 * <http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/>
39 *
40 * @package decode
41 * @subpackage x-mac
42 */
43
44/**
45 * Decode x-mac-devanagari string
46 * @param string $string String to decode
47 * @return string $string Html formated string
48 */
49function charset_decode_x_mac_devanagari ($string) {
50    // don't do decoding when there are no 8bit symbols
51    if (! sq_is8bit($string,'x-mac-devanagari'))
52        return $string;
53
54    // Zero joint characters
55    $string=str_replace("\xA1\xE9",'&#2384;',$string);
56    $string=str_replace("\xA6\xE9",'&#2316;',$string);
57    $string=str_replace("\xA7\xE9",'&#2401;',$string);
58    $string=str_replace("\xAA\xE9",'&#2400;',$string);
59    $string=str_replace("\xDB\xE9",'&#2402;',$string);
60    $string=str_replace("\xDC\xE9",'&#2403;',$string);
61    $string=str_replace("\xDF\xE9",'&#2372;',$string);
62    $string=str_replace("\xE8\xE8",'&#2381;&#8204;',$string);
63    $string=str_replace("\xE8\xE9",'&#2381;&#8205;',$string);
64    $string=str_replace("\xEA\xE9",'&#2365;',$string);
65
66    // Main replace array
67    $mac_devanagari = array(
68        "\x80" => '&#215;',
69        "\x81" => '&#8722;',
70        "\x82" => '&#8211;',
71        "\x83" => '&#8212;',
72        "\x84" => '&#8216;',
73        "\x85" => '&#8217;',
74        "\x86" => '&#8230;',
75        "\x87" => '&#8226;',
76        "\x88" => '&#169;',
77        "\x89" => '&#174;',
78        "\x8A" => '&#8482;',
79        "\x90" => '&#2405;',
80        "\x91" => '&#2416;',
81        "\xA1" => '&#2305;',
82        "\xA2" => '&#2306;',
83        "\xA3" => '&#2307;',
84        "\xA4" => '&#2309;',
85        "\xA5" => '&#2310;',
86        "\xA6" => '&#2311;',
87        "\xA7" => '&#2312;',
88        "\xA8" => '&#2313;',
89        "\xA9" => '&#2314;',
90        "\xAA" => '&#2315;',
91        "\xAB" => '&#2318;',
92        "\xAC" => '&#2319;',
93        "\xAD" => '&#2320;',
94        "\xAE" => '&#2317;',
95        "\xAF" => '&#2322;',
96        "\xB0" => '&#2323;',
97        "\xB1" => '&#2324;',
98        "\xB2" => '&#2321;',
99        "\xB3" => '&#2325;',
100        "\xB4" => '&#2326;',
101        "\xB5" => '&#2327;',
102        "\xB6" => '&#2328;',
103        "\xB7" => '&#2329;',
104        "\xB8" => '&#2330;',
105        "\xB9" => '&#2331;',
106        "\xBA" => '&#2332;',
107        "\xBB" => '&#2333;',
108        "\xBC" => '&#2334;',
109        "\xBD" => '&#2335;',
110        "\xBE" => '&#2336;',
111        "\xBF" => '&#2337;',
112        "\xC0" => '&#2338;',
113        "\xC1" => '&#2339;',
114        "\xC2" => '&#2340;',
115        "\xC3" => '&#2341;',
116        "\xC4" => '&#2342;',
117        "\xC5" => '&#2343;',
118        "\xC6" => '&#2344;',
119        "\xC7" => '&#2345;',
120        "\xC8" => '&#2346;',
121        "\xC9" => '&#2347;',
122        "\xCA" => '&#2348;',
123        "\xCB" => '&#2349;',
124        "\xCC" => '&#2350;',
125        "\xCD" => '&#2351;',
126        "\xCE" => '&#2399;',
127        "\xCF" => '&#2352;',
128        "\xD0" => '&#2353;',
129        "\xD1" => '&#2354;',
130        "\xD2" => '&#2355;',
131        "\xD3" => '&#2356;',
132        "\xD4" => '&#2357;',
133        "\xD5" => '&#2358;',
134        "\xD6" => '&#2359;',
135        "\xD7" => '&#2360;',
136        "\xD8" => '&#2361;',
137        "\xD9" => '&#8206;',
138        "\xDA" => '&#2366;',
139        "\xDB" => '&#2367;',
140        "\xDC" => '&#2368;',
141        "\xDD" => '&#2369;',
142        "\xDE" => '&#2370;',
143        "\xDF" => '&#2371;',
144        "\xE0" => '&#2374;',
145        "\xE1" => '&#2375;',
146        "\xE2" => '&#2376;',
147        "\xE3" => '&#2373;',
148        "\xE4" => '&#2378;',
149        "\xE5" => '&#2379;',
150        "\xE6" => '&#2380;',
151        "\xE7" => '&#2377;',
152        "\xE8" => '&#2381;',
153        "\xE9" => '&#2364;',
154        "\xEA" => '&#2404;',
155        "\xF1" => '&#2406;',
156        "\xF2" => '&#2407;',
157        "\xF3" => '&#2408;',
158        "\xF4" => '&#2409;',
159        "\xF5" => '&#2410;',
160        "\xF6" => '&#2411;',
161        "\xF7" => '&#2412;',
162        "\xF8" => '&#2413;',
163        "\xF9" => '&#2414;',
164        "\xFA" => '&#2415;');
165
166    $string = str_replace(array_keys($mac_devanagari), array_values($mac_devanagari), $string);
167
168    return $string;
169}
170
171