]> git.saurik.com Git - apple/xnu.git/blame - bsd/hfs/hfs_encodings.c
xnu-1504.9.26.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_encodings.c
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
5d5c5d0d 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b 27 */
2d21ac55 28#if HFS
1c79356b
A
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
1c79356b
A
33#include <sys/malloc.h>
34#include <sys/queue.h>
35#include <sys/utfconv.h>
2d21ac55
A
36#include <kern/host.h>
37#include <mach/host_priv.h>
b0d623f7
A
38#include <libkern/OSKextLib.h>
39#include <libkern/OSKextLibPrivate.h>
1c79356b
A
40
41#include "hfs.h"
42
43
91447636
A
44lck_grp_t * encodinglst_lck_grp;
45lck_grp_attr_t * encodinglst_lck_grp_attr;
46lck_attr_t * encodinglst_lck_attr;
47
48
1c79356b
A
49/* hfs encoding converter list */
50SLIST_HEAD(encodinglst, hfs_encoding) hfs_encoding_list = {0};
91447636
A
51
52lck_mtx_t encodinglst_mutex;
53
1c79356b
A
54
55
56/* hfs encoding converter entry */
57struct hfs_encoding {
58 SLIST_ENTRY(hfs_encoding) link;
59 int refcount;
60 int kmod_id;
2d21ac55 61 u_int32_t encoding;
1c79356b
A
62 hfs_to_unicode_func_t get_unicode_func;
63 unicode_to_hfs_func_t get_hfsname_func;
64};
65
1c79356b
A
66#define MAX_HFS_UNICODE_CHARS (15*5)
67
2d21ac55 68static int unicode_to_mac_roman(UniChar *uni_str, u_int32_t unicodeChars, Str31 hfs_str);
1c79356b
A
69
70void
71hfs_converterinit(void)
72{
73 SLIST_INIT(&hfs_encoding_list);
91447636
A
74
75 encodinglst_lck_grp_attr= lck_grp_attr_alloc_init();
91447636 76 encodinglst_lck_grp = lck_grp_alloc_init("cnode_hash", encodinglst_lck_grp_attr);
91447636 77 encodinglst_lck_attr = lck_attr_alloc_init();
91447636
A
78
79 lck_mtx_init(&encodinglst_mutex, encodinglst_lck_grp, encodinglst_lck_attr);
1c79356b
A
80
81 /*
82 * add resident MacRoman converter and take a reference
83 * since its always "loaded".
84 */
85 hfs_addconverter(0, kTextEncodingMacRoman, mac_roman_to_unicode, unicode_to_mac_roman);
86 SLIST_FIRST(&hfs_encoding_list)->refcount++;
87}
88
89
90/*
91 * hfs_addconverter - add an HFS encoding converter
92 *
93 * This is called exclusivly by kernel loadable modules
94 * (like HFS_Japanese.kmod) to register hfs encoding
95 * conversion routines.
96 *
97 */
98int
2d21ac55 99hfs_addconverter(int id, u_int32_t encoding, hfs_to_unicode_func_t get_unicode, unicode_to_hfs_func_t get_hfsname)
1c79356b
A
100{
101 struct hfs_encoding *encp;
102
103 MALLOC(encp, struct hfs_encoding *, sizeof(struct hfs_encoding), M_TEMP, M_WAITOK);
104
91447636 105 lck_mtx_lock(&encodinglst_mutex);
1c79356b
A
106
107 encp->link.sle_next = NULL;
108 encp->refcount = 0;
109 encp->encoding = encoding;
110 encp->get_unicode_func = get_unicode;
111 encp->get_hfsname_func = get_hfsname;
112 encp->kmod_id = id;
113 SLIST_INSERT_HEAD(&hfs_encoding_list, encp, link);
114
91447636 115 lck_mtx_unlock(&encodinglst_mutex);
1c79356b
A
116 return (0);
117}
118
119
120/*
121 * hfs_remconverter - remove an HFS encoding converter
122 *
123 * Can be called by a kernel loadable module's finalize
124 * routine to remove an encoding converter so that the
125 * module (i.e. the code) can be unloaded.
126 *
127 * However, in the normal case, the removing and unloading
128 * of these converters is done in hfs_relconverter.
129 * The call is initiated from within the kernel during the unmounting of an hfs voulume.
130 */
131int
2d21ac55 132hfs_remconverter(int id, u_int32_t encoding)
1c79356b
A
133{
134 struct hfs_encoding *encp;
1c79356b 135
91447636 136 lck_mtx_lock(&encodinglst_mutex);
1c79356b
A
137 SLIST_FOREACH(encp, &hfs_encoding_list, link) {
138 if (encp->encoding == encoding && encp->kmod_id == id) {
139 encp->refcount--;
140
141 /* if converter is no longer in use, release it */
142 if (encp->refcount <= 0 && encp->kmod_id != 0) {
143 SLIST_REMOVE(&hfs_encoding_list, encp, hfs_encoding, link);
91447636 144 lck_mtx_unlock(&encodinglst_mutex);
1c79356b 145 FREE(encp, M_TEMP);
91447636 146 return (0);
1c79356b 147 } else {
91447636
A
148 lck_mtx_unlock(&encodinglst_mutex);
149 return (1); /* busy */
1c79356b
A
150 }
151 break;
152 }
153 }
91447636 154 lck_mtx_unlock(&encodinglst_mutex);
1c79356b 155
91447636 156 return (0);
1c79356b
A
157}
158
159
160/*
161 * hfs_getconverter - get HFS encoding converters
162 *
163 * Normally called during the mounting of an hfs voulume.
164 */
165int
2d21ac55 166hfs_getconverter(u_int32_t encoding, hfs_to_unicode_func_t *get_unicode, unicode_to_hfs_func_t *get_hfsname)
1c79356b
A
167{
168 struct hfs_encoding *encp;
169 int found = 0;
170
91447636 171 lck_mtx_lock(&encodinglst_mutex);
1c79356b
A
172 SLIST_FOREACH(encp, &hfs_encoding_list, link) {
173 if (encp->encoding == encoding) {
174 found = 1;
175 *get_unicode = encp->get_unicode_func;
176 *get_hfsname = encp->get_hfsname_func;
177 ++encp->refcount;
178 break;
179 }
180 }
91447636 181 lck_mtx_unlock(&encodinglst_mutex);
1c79356b
A
182
183 if (!found) {
184 *get_unicode = NULL;
185 *get_hfsname = NULL;
186 return (EINVAL);
187 }
188
189 return (0);
190}
191
192
193/*
194 * hfs_relconverter - release interest in an HFS encoding converter
195 *
196 * Normally called during the unmounting of an hfs voulume.
197 */
198int
2d21ac55 199hfs_relconverter(u_int32_t encoding)
1c79356b
A
200{
201 struct hfs_encoding *encp;
1c79356b 202
91447636 203 lck_mtx_lock(&encodinglst_mutex);
1c79356b
A
204 SLIST_FOREACH(encp, &hfs_encoding_list, link) {
205 if (encp->encoding == encoding) {
1c79356b
A
206 encp->refcount--;
207
208 /* if converter is no longer in use, release it */
209 if (encp->refcount <= 0 && encp->kmod_id != 0) {
b0d623f7 210 uint32_t loadTag = (uint32_t)encp->kmod_id;
1c79356b
A
211
212 SLIST_REMOVE(&hfs_encoding_list, encp, hfs_encoding, link);
91447636
A
213 lck_mtx_unlock(&encodinglst_mutex);
214
215 FREE(encp, M_TEMP);
b0d623f7 216 (void)OSKextUnloadKextWithLoadTag(loadTag);
91447636 217 return (0);
1c79356b 218 }
91447636
A
219 lck_mtx_unlock(&encodinglst_mutex);
220 return (0);
1c79356b
A
221 }
222 }
91447636 223 lck_mtx_unlock(&encodinglst_mutex);
1c79356b 224
91447636 225 return (EINVAL);
1c79356b
A
226}
227
228
229/*
230 * Convert HFS encoded string into UTF-8
231 *
232 * Unicode output is fully decomposed
233 * '/' chars are converted to ':'
234 */
235int
2d21ac55 236hfs_to_utf8(ExtendedVCB *vcb, const Str31 hfs_str, ByteCount maxDstLen, ByteCount *actualDstLen, unsigned char* dstStr)
1c79356b
A
237{
238 int error;
239 UniChar uniStr[MAX_HFS_UNICODE_CHARS];
240 ItemCount uniCount;
241 size_t utf8len;
242 hfs_to_unicode_func_t hfs_get_unicode = VCBTOHFS(vcb)->hfs_get_unicode;
243
244 error = hfs_get_unicode(hfs_str, uniStr, MAX_HFS_UNICODE_CHARS, &uniCount);
245
246 if (uniCount == 0)
247 error = EINVAL;
248
249 if (error == 0) {
250 error = utf8_encodestr(uniStr, uniCount * sizeof(UniChar), dstStr, &utf8len, maxDstLen , ':', 0);
251 if (error == ENAMETOOLONG)
252 *actualDstLen = utf8_encodelen(uniStr, uniCount * sizeof(UniChar), ':', 0);
253 else
254 *actualDstLen = utf8len;
255 }
256
257 return error;
258}
259
260
261/*
262 * When an HFS name cannot be encoded with the current
263 * volume encoding then MacRoman is used as a fallback.
264 */
265int
2d21ac55 266mac_roman_to_utf8(const Str31 hfs_str, ByteCount maxDstLen, ByteCount *actualDstLen, unsigned char* dstStr)
1c79356b
A
267{
268 int error;
269 UniChar uniStr[MAX_HFS_UNICODE_CHARS];
270 ItemCount uniCount;
271 size_t utf8len;
272
273 error = mac_roman_to_unicode(hfs_str, uniStr, MAX_HFS_UNICODE_CHARS, &uniCount);
274
275 if (uniCount == 0)
276 error = EINVAL;
277
278 if (error == 0) {
279 error = utf8_encodestr(uniStr, uniCount * sizeof(UniChar), dstStr, &utf8len, maxDstLen , ':', 0);
280 if (error == ENAMETOOLONG)
281 *actualDstLen = utf8_encodelen(uniStr, uniCount * sizeof(UniChar), ':', 0);
282 else
283 *actualDstLen = utf8len;
284 }
285
286 return error;
287}
288
289
9bccf70c
A
290/*
291 * Convert Unicode string into HFS encoding
292 *
293 * ':' chars are converted to '/'
294 * Assumes input represents fully decomposed Unicode
295 */
296int
297unicode_to_hfs(ExtendedVCB *vcb, ByteCount srcLen, u_int16_t* srcStr, Str31 dstStr, int retry)
298{
299 int error;
300 unicode_to_hfs_func_t hfs_get_hfsname = VCBTOHFS(vcb)->hfs_get_hfsname;
301
302 error = hfs_get_hfsname(srcStr, srcLen/sizeof(UniChar), dstStr);
303 if (error && retry) {
304 error = unicode_to_mac_roman(srcStr, srcLen/sizeof(UniChar), dstStr);
305 }
306 return error;
307}
308
1c79356b
A
309/*
310 * Convert UTF-8 string into HFS encoding
311 *
312 * ':' chars are converted to '/'
313 * Assumes input represents fully decomposed Unicode
314 */
315int
9bccf70c 316utf8_to_hfs(ExtendedVCB *vcb, ByteCount srcLen, const unsigned char* srcStr, Str31 dstStr/*, int retry*/)
1c79356b
A
317{
318 int error;
319 UniChar uniStr[MAX_HFS_UNICODE_CHARS];
320 size_t ucslen;
1c79356b
A
321
322 error = utf8_decodestr(srcStr, srcLen, uniStr, &ucslen, sizeof(uniStr), ':', 0);
323 if (error == 0)
9bccf70c 324 error = unicode_to_hfs(vcb, ucslen, uniStr, dstStr, 1);
1c79356b
A
325
326 return error;
327}
328
329int
330utf8_to_mac_roman(ByteCount srcLen, const unsigned char* srcStr, Str31 dstStr)
331{
332 int error;
333 UniChar uniStr[MAX_HFS_UNICODE_CHARS];
334 size_t ucslen;
335
336 error = utf8_decodestr(srcStr, srcLen, uniStr, &ucslen, sizeof(uniStr), ':', 0);
337 if (error == 0)
338 error = unicode_to_mac_roman(uniStr, ucslen/sizeof(UniChar), dstStr);
339
340 return error;
341}
342
343/*
344 * HFS MacRoman to/from Unicode conversions are built into the kernel
345 * All others hfs encodings are loadable.
346 */
347
348/* 0x00A0 - 0x00FF = Latin 1 Supplement (30 total) */
2d21ac55 349static u_int8_t gLatin1Table[] = {
1c79356b
A
350 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
351 /* 0x00A0 */ 0xCA, 0xC1, 0xA2, 0xA3, 0xDB, 0xB4, '?', 0xA4, 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, '?', 0xA8, 0xF8,
352 /* 0x00B0 */ 0xA1, 0XB1, '?', '?', 0xAB, 0xB5, 0xA6, 0xe1, 0xFC, '?', 0xBC, 0xC8, '?', '?', '?', 0xC0,
353 /* 0x00C0 */ '?', '?', '?', '?', '?', '?', 0xAE, '?', '?', '?', '?', '?', '?', '?', '?', '?',
354 /* 0x00D0 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xAF, '?', '?', '?', '?', '?', '?', 0xA7,
355 /* 0x00E0 */ '?', '?', '?', '?', '?', '?', 0xBE, '?', '?', '?', '?', '?', '?', '?', '?', '?',
356 /* 0x00F0 */ '?', '?', '?', '?', '?', '?', '?', 0xD6, 0xBF, '?', '?', '?', '?', '?', '?', '?'
357};
358
359/* 0x02C0 - 0x02DF = Spacing Modifiers (8 total) */
2d21ac55 360static u_int8_t gSpaceModsTable[] = {
1c79356b
A
361 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
362 /* 0x02C0 */ '?', '?', '?', '?', '?', '?', 0xF6, 0xFF, '?', '?', '?', '?', '?', '?', '?', '?',
363 /* 0x02D0 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xF9, 0xFA, 0xFB, 0xFE, 0xF7, 0xFD, '?', '?'
364};
365
366/* 0x2010 - 0x20AF = General Punctuation (17 total) */
2d21ac55 367static u_int8_t gPunctTable[] = {
1c79356b
A
368 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
369 /* 0x2010 */ '?', '?', '?', 0xd0, 0xd1, '?', '?', '?', 0xd4, 0xd5, 0xe2, '?', 0xd2, 0xd3, 0xe3, '?',
370 /* 0x2020 */ 0xa0, 0xe0, 0xa5, '?', '?', '?', 0xc9, '?', '?', '?', '?', '?', '?', '?', '?', '?',
371 /* 0x2030 */ 0xe4, '?', '?', '?', '?', '?', '?', '?', '?', 0xdc, 0xdd, '?', '?', '?', '?', '?',
372 /* 0x2040 */ '?', '?', '?', '?', 0xda, '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
373 /* 0x2050 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
374 /* 0x2060 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
375 /* 0x2070 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
376 /* 0x2080 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
377 /* 0x2090 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
378 /* 0x20A0 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', 0xdb, '?', '?', '?'
379};
380
381/* 0x22xx = Mathematical Operators (11 total) */
2d21ac55 382static u_int8_t gMathTable[] = {
1c79356b
A
383 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
384 /* 0x2200 */ '?', '?', 0xb6, '?', '?', '?', 0xc6, '?', '?', '?', '?', '?', '?', '?', '?', 0xb8,
385 /* 0x2210 */ '?', 0xb7, '?', '?', '?', '?', '?', '?', '?', '?', 0xc3, '?', '?', '?', 0xb0, '?',
386 /* 0x2220 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', 0xba, '?', '?', '?', '?',
387 /* 0x2230 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
388 /* 0x2240 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xc5, '?', '?', '?', '?', '?', '?', '?',
389 /* 0x2250 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
390 /* 0x2260 */ 0xad, '?', '?', '?', 0xb2, 0xb3, '?', '?'
391};
392
393/* */
2d21ac55 394static u_int8_t gReverseCombTable[] = {
1c79356b
A
395 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
396 /* 0x40 */ 0xDA, 0x40, 0xDA, 0xDA, 0xDA, 0x56, 0xDA, 0xDA, 0xDA, 0x6C, 0xDA, 0xDA, 0xDA, 0xDA, 0x82, 0x98,
397 /* 0x50 */ 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xAE, 0xDA, 0xDA, 0xDA, 0xC4, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA,
398 /* 0x60 */ 0xDA, 0x4B, 0xDA, 0xDA, 0xDA, 0x61, 0xDA, 0xDA, 0xDA, 0x77, 0xDA, 0xDA, 0xDA, 0xDA, 0x8D, 0xA3,
399 /* 0x70 */ 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xB9, 0xDA, 0xDA, 0xDA, 0xCF, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA,
400
401 /* Combining Diacritical Marks (0x0300 - 0x030A) */
402 /* 0 1 2 3 4 5 6 7 8 9 A */
403 /* 'A' */
404 /* 0x0300 */ 0xCB, 0xE7, 0xE5, 0xCC, '?', '?', '?', '?', 0x80, '?', 0x81,
405
406 /* 'a' */
407 /* 0x0300 */ 0x88, 0x87, 0x89, 0x8B, '?', '?', '?', '?', 0x8A, '?', 0x8C,
408
409 /* 'E' */
410 /* 0x0300 */ 0xE9, 0x83, 0xE6, '?', '?', '?', '?', '?', 0xE8, '?', '?',
411
412 /* 'e' */
413 /* 0x0300 */ 0x8F, 0x8E, 0x90, '?', '?', '?', '?', '?', 0x91, '?', '?',
414
415 /* 'I' */
416 /* 0x0300 */ 0xED, 0xEA, 0xEB, '?', '?', '?', '?', '?', 0xEC, '?', '?',
417
418 /* 'i' */
419 /* 0x0300 */ 0x93, 0x92, 0x94, '?', '?', '?', '?', '?', 0x95, '?', '?',
420
421 /* 'N' */
422 /* 0x0300 */ '?', '?', '?', 0x84, '?', '?', '?', '?', '?', '?', '?',
423
424 /* 'n' */
425 /* 0x0300 */ '?', '?', '?', 0x96, '?', '?', '?', '?', '?', '?', '?',
426
427 /* 'O' */
428 /* 0x0300 */ 0xF1, 0xEE, 0xEF, 0xCD, '?', '?', '?', '?', 0x85, '?', '?',
429
430 /* 'o' */
431 /* 0x0300 */ 0x98, 0x97, 0x99, 0x9B, '?', '?', '?', '?', 0x9A, '?', '?',
432
433 /* 'U' */
434 /* 0x0300 */ 0xF4, 0xF2, 0xF3, '?', '?', '?', '?', '?', 0x86, '?', '?',
435
436 /* 'u' */
437 /* 0x0300 */ 0x9D, 0x9C, 0x9E, '?', '?', '?', '?', '?', 0x9F, '?', '?',
438
439 /* 'Y' */
440 /* 0x0300 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xD9, '?', '?',
441
442 /* 'y' */
443 /* 0x0300 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xD8, '?', '?',
444
445 /* else */
446 /* 0x0300 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?'
447};
448
449
450/*
451 * Convert Unicode string into HFS MacRoman encoding
452 *
453 * Assumes Unicode input is fully decomposed
454 */
2d21ac55 455static int unicode_to_mac_roman(UniChar *uni_str, u_int32_t unicodeChars, Str31 hfs_str)
1c79356b 456{
2d21ac55 457 u_int8_t *p;
1c79356b
A
458 const UniChar *u;
459 UniChar c;
460 UniChar mask;
2d21ac55
A
461 u_int16_t inputChars;
462 u_int16_t pascalChars;
1c79356b 463 OSErr result = noErr;
2d21ac55
A
464 u_int8_t lsb;
465 u_int8_t prevChar;
466 u_int8_t mc;
1c79356b
A
467
468 mask = (UniChar) 0xFF80;
469 p = &hfs_str[1];
470 u = uni_str;
471 inputChars = unicodeChars;
472 pascalChars = prevChar = 0;
473
474 while (inputChars) {
475 c = *(u++);
2d21ac55 476 lsb = (u_int8_t) c;
1c79356b
A
477
478 /*
479 * If its not 7-bit ascii, then we need to map it
480 */
481 if ( c & mask ) {
482 mc = '?';
483 switch (c & 0xFF00) {
484 case 0x0000:
485 if (lsb >= 0xA0)
486 mc = gLatin1Table[lsb - 0xA0];
487 break;
488
489 case 0x0200:
490 if (lsb >= 0xC0 && lsb <= 0xDF)
491 mc = gSpaceModsTable[lsb - 0xC0];
492 break;
493
494 case 0x2000:
495 if (lsb >= 0x10 && lsb <= 0xAF)
496 mc = gPunctTable[lsb- 0x10];
497 break;
498
499 case 0x2200:
500 if (lsb <= 0x68)
501 mc = gMathTable[lsb];
502 break;
503
504 case 0x0300:
505 if (c <= 0x030A) {
506 if (prevChar >= 'A' && prevChar < 'z') {
507 mc = gReverseCombTable[gReverseCombTable[prevChar - 0x40] + lsb];
508 --p; /* backup over base char */
509 --pascalChars;
510 }
511 } else {
512 switch (c) {
513 case 0x0327: /* combining cedilla */
514 if (prevChar == 'C')
515 mc = 0x82;
516 else if (prevChar == 'c')
517 mc = 0x8D;
518 else
519 break;
520 --p; /* backup over base char */
521 --pascalChars;
522 break;
523
524 case 0x03A9: mc = 0xBD; break; /* omega */
525
526 case 0x03C0: mc = 0xB9; break; /* pi */
527 }
528 }
529 break;
530
531 default:
532 switch (c) {
533 case 0x0131: mc = 0xf5; break; /* dotless i */
534
535 case 0x0152: mc = 0xce; break; /* OE */
536
537 case 0x0153: mc = 0xcf; break; /* oe */
538
539