2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #include <sys/param.h>
24 #include <sys/systm.h>
25 #include <sys/kernel.h>
27 #include <sys/malloc.h>
28 #include <sys/queue.h>
29 #include <sys/utfconv.h>
34 /* hfs encoding converter list */
35 SLIST_HEAD(encodinglst
, hfs_encoding
) hfs_encoding_list
= {0};
36 decl_simple_lock_data(,hfs_encoding_list_slock
);
39 /* hfs encoding converter entry */
41 SLIST_ENTRY(hfs_encoding
) link
;
45 hfs_to_unicode_func_t get_unicode_func
;
46 unicode_to_hfs_func_t get_hfsname_func
;
49 /* XXX We should use an "official" interface! */
50 extern kern_return_t
kmod_destroy(host_priv_t host_priv
, kmod_t id
);
51 extern struct host realhost
;
53 #define MAX_HFS_UNICODE_CHARS (15*5)
55 int mac_roman_to_unicode(Str31 hfs_str
, UniChar
*uni_str
, UInt32 maxCharLen
, UInt32
*usedCharLen
);
57 static int unicode_to_mac_roman(UniChar
*uni_str
, UInt32 unicodeChars
, Str31 hfs_str
);
61 hfs_converterinit(void)
63 SLIST_INIT(&hfs_encoding_list
);
64 simple_lock_init(&hfs_encoding_list_slock
);
67 * add resident MacRoman converter and take a reference
68 * since its always "loaded".
70 hfs_addconverter(0, kTextEncodingMacRoman
, mac_roman_to_unicode
, unicode_to_mac_roman
);
71 SLIST_FIRST(&hfs_encoding_list
)->refcount
++;
76 * hfs_addconverter - add an HFS encoding converter
78 * This is called exclusivly by kernel loadable modules
79 * (like HFS_Japanese.kmod) to register hfs encoding
80 * conversion routines.
84 hfs_addconverter(int id
, UInt32 encoding
, hfs_to_unicode_func_t get_unicode
, unicode_to_hfs_func_t get_hfsname
)
86 struct hfs_encoding
*encp
;
88 MALLOC(encp
, struct hfs_encoding
*, sizeof(struct hfs_encoding
), M_TEMP
, M_WAITOK
);
90 simple_lock(&hfs_encoding_list_slock
);
92 encp
->link
.sle_next
= NULL
;
94 encp
->encoding
= encoding
;
95 encp
->get_unicode_func
= get_unicode
;
96 encp
->get_hfsname_func
= get_hfsname
;
98 SLIST_INSERT_HEAD(&hfs_encoding_list
, encp
, link
);
100 simple_unlock(&hfs_encoding_list_slock
);
106 * hfs_remconverter - remove an HFS encoding converter
108 * Can be called by a kernel loadable module's finalize
109 * routine to remove an encoding converter so that the
110 * module (i.e. the code) can be unloaded.
112 * However, in the normal case, the removing and unloading
113 * of these converters is done in hfs_relconverter.
114 * The call is initiated from within the kernel during the unmounting of an hfs voulume.
117 hfs_remconverter(int id
, UInt32 encoding
)
119 struct hfs_encoding
*encp
;
122 simple_lock(&hfs_encoding_list_slock
);
123 SLIST_FOREACH(encp
, &hfs_encoding_list
, link
) {
124 if (encp
->encoding
== encoding
&& encp
->kmod_id
== id
) {
127 /* if converter is no longer in use, release it */
128 if (encp
->refcount
<= 0 && encp
->kmod_id
!= 0) {
129 SLIST_REMOVE(&hfs_encoding_list
, encp
, hfs_encoding
, link
);
137 simple_unlock(&hfs_encoding_list_slock
);
144 * hfs_getconverter - get HFS encoding converters
146 * Normally called during the mounting of an hfs voulume.
149 hfs_getconverter(UInt32 encoding
, hfs_to_unicode_func_t
*get_unicode
, unicode_to_hfs_func_t
*get_hfsname
)
151 struct hfs_encoding
*encp
;
154 simple_lock(&hfs_encoding_list_slock
);
155 SLIST_FOREACH(encp
, &hfs_encoding_list
, link
) {
156 if (encp
->encoding
== encoding
) {
158 *get_unicode
= encp
->get_unicode_func
;
159 *get_hfsname
= encp
->get_hfsname_func
;
164 simple_unlock(&hfs_encoding_list_slock
);
177 * hfs_relconverter - release interest in an HFS encoding converter
179 * Normally called during the unmounting of an hfs voulume.
182 hfs_relconverter(UInt32 encoding
)
184 struct hfs_encoding
*encp
;
187 simple_lock(&hfs_encoding_list_slock
);
188 SLIST_FOREACH(encp
, &hfs_encoding_list
, link
) {
189 if (encp
->encoding
== encoding
) {
193 /* if converter is no longer in use, release it */
194 if (encp
->refcount
<= 0 && encp
->kmod_id
!= 0) {
195 int id
= encp
->kmod_id
;
197 SLIST_REMOVE(&hfs_encoding_list
, encp
, hfs_encoding
, link
);
201 simple_unlock(&hfs_encoding_list_slock
);
202 kmod_destroy(host_priv_self(), id
);
203 simple_lock(&hfs_encoding_list_slock
);
208 simple_unlock(&hfs_encoding_list_slock
);
210 return (found
? 0 : EINVAL
);
215 * Convert HFS encoded string into UTF-8
217 * Unicode output is fully decomposed
218 * '/' chars are converted to ':'
221 hfs_to_utf8(ExtendedVCB
*vcb
, Str31 hfs_str
, ByteCount maxDstLen
, ByteCount
*actualDstLen
, unsigned char* dstStr
)
224 UniChar uniStr
[MAX_HFS_UNICODE_CHARS
];
227 hfs_to_unicode_func_t hfs_get_unicode
= VCBTOHFS(vcb
)->hfs_get_unicode
;
229 error
= hfs_get_unicode(hfs_str
, uniStr
, MAX_HFS_UNICODE_CHARS
, &uniCount
);
235 error
= utf8_encodestr(uniStr
, uniCount
* sizeof(UniChar
), dstStr
, &utf8len
, maxDstLen
, ':', 0);
236 if (error
== ENAMETOOLONG
)
237 *actualDstLen
= utf8_encodelen(uniStr
, uniCount
* sizeof(UniChar
), ':', 0);
239 *actualDstLen
= utf8len
;
247 * When an HFS name cannot be encoded with the current
248 * volume encoding then MacRoman is used as a fallback.
251 mac_roman_to_utf8(Str31 hfs_str
, ByteCount maxDstLen
, ByteCount
*actualDstLen
, unsigned char* dstStr
)
254 UniChar uniStr
[MAX_HFS_UNICODE_CHARS
];
258 error
= mac_roman_to_unicode(hfs_str
, uniStr
, MAX_HFS_UNICODE_CHARS
, &uniCount
);
264 error
= utf8_encodestr(uniStr
, uniCount
* sizeof(UniChar
), dstStr
, &utf8len
, maxDstLen
, ':', 0);
265 if (error
== ENAMETOOLONG
)
266 *actualDstLen
= utf8_encodelen(uniStr
, uniCount
* sizeof(UniChar
), ':', 0);
268 *actualDstLen
= utf8len
;
276 * Convert Unicode string into HFS encoding
278 * ':' chars are converted to '/'
279 * Assumes input represents fully decomposed Unicode
282 unicode_to_hfs(ExtendedVCB
*vcb
, ByteCount srcLen
, u_int16_t
* srcStr
, Str31 dstStr
, int retry
)
285 unicode_to_hfs_func_t hfs_get_hfsname
= VCBTOHFS(vcb
)->hfs_get_hfsname
;
287 error
= hfs_get_hfsname(srcStr
, srcLen
/sizeof(UniChar
), dstStr
);
288 if (error
&& retry
) {
289 error
= unicode_to_mac_roman(srcStr
, srcLen
/sizeof(UniChar
), dstStr
);
295 * Convert UTF-8 string into HFS encoding
297 * ':' chars are converted to '/'
298 * Assumes input represents fully decomposed Unicode
301 utf8_to_hfs(ExtendedVCB
*vcb
, ByteCount srcLen
, const unsigned char* srcStr
, Str31 dstStr
/*, int retry*/)
304 UniChar uniStr
[MAX_HFS_UNICODE_CHARS
];
307 error
= utf8_decodestr(srcStr
, srcLen
, uniStr
, &ucslen
, sizeof(uniStr
), ':', 0);
309 error
= unicode_to_hfs(vcb
, ucslen
, uniStr
, dstStr
, 1);
315 utf8_to_mac_roman(ByteCount srcLen
, const unsigned char* srcStr
, Str31 dstStr
)
318 UniChar uniStr
[MAX_HFS_UNICODE_CHARS
];
321 error
= utf8_decodestr(srcStr
, srcLen
, uniStr
, &ucslen
, sizeof(uniStr
), ':', 0);
323 error
= unicode_to_mac_roman(uniStr
, ucslen
/sizeof(UniChar
), dstStr
);
329 * HFS MacRoman to/from Unicode conversions are built into the kernel
330 * All others hfs encodings are loadable.
333 /* 0x00A0 - 0x00FF = Latin 1 Supplement (30 total) */
334 static UInt8 gLatin1Table
[] = {
335 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
336 /* 0x00A0 */ 0xCA, 0xC1, 0xA2, 0xA3, 0xDB, 0xB4, '?', 0xA4, 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, '?', 0xA8, 0xF8,
337 /* 0x00B0 */ 0xA1, 0XB1, '?', '?', 0xAB, 0xB5, 0xA6, 0xe1, 0xFC, '?', 0xBC, 0xC8, '?', '?', '?', 0xC0,
338 /* 0x00C0 */ '?', '?', '?', '?', '?', '?', 0xAE, '?', '?', '?', '?', '?', '?', '?', '?', '?',
339 /* 0x00D0 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xAF, '?', '?', '?', '?', '?', '?', 0xA7,
340 /* 0x00E0 */ '?', '?', '?', '?', '?', '?', 0xBE, '?', '?', '?', '?', '?', '?', '?', '?', '?',
341 /* 0x00F0 */ '?', '?', '?', '?', '?', '?', '?', 0xD6, 0xBF, '?', '?', '?', '?', '?', '?', '?'
344 /* 0x02C0 - 0x02DF = Spacing Modifiers (8 total) */
345 static UInt8 gSpaceModsTable
[] = {
346 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
347 /* 0x02C0 */ '?', '?', '?', '?', '?', '?', 0xF6, 0xFF, '?', '?', '?', '?', '?', '?', '?', '?',
348 /* 0x02D0 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xF9, 0xFA, 0xFB, 0xFE, 0xF7, 0xFD, '?', '?'
351 /* 0x2010 - 0x20AF = General Punctuation (17 total) */
352 static UInt8 gPunctTable
[] = {
353 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
354 /* 0x2010 */ '?', '?', '?', 0xd0, 0xd1, '?', '?', '?', 0xd4, 0xd5, 0xe2, '?', 0xd2, 0xd3, 0xe3, '?',
355 /* 0x2020 */ 0xa0, 0xe0, 0xa5, '?', '?', '?', 0xc9, '?', '?', '?', '?', '?', '?', '?', '?', '?',
356 /* 0x2030 */ 0xe4, '?', '?', '?', '?', '?', '?', '?', '?', 0xdc, 0xdd, '?', '?', '?', '?', '?',
357 /* 0x2040 */ '?', '?', '?', '?', 0xda, '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
358 /* 0x2050 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
359 /* 0x2060 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
360 /* 0x2070 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
361 /* 0x2080 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
362 /* 0x2090 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
363 /* 0x20A0 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', 0xdb, '?', '?', '?'
366 /* 0x22xx = Mathematical Operators (11 total) */
367 static UInt8 gMathTable
[] = {
368 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
369 /* 0x2200 */ '?', '?', 0xb6, '?', '?', '?', 0xc6, '?', '?', '?', '?', '?', '?', '?', '?', 0xb8,
370 /* 0x2210 */ '?', 0xb7, '?', '?', '?', '?', '?', '?', '?', '?', 0xc3, '?', '?', '?', 0xb0, '?',
371 /* 0x2220 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', 0xba, '?', '?', '?', '?',
372 /* 0x2230 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
373 /* 0x2240 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xc5, '?', '?', '?', '?', '?', '?', '?',
374 /* 0x2250 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
375 /* 0x2260 */ 0xad, '?', '?', '?', 0xb2, 0xb3, '?', '?'
379 static UInt8 gReverseCombTable
[] = {
380 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
381 /* 0x40 */ 0xDA, 0x40, 0xDA, 0xDA, 0xDA, 0x56, 0xDA, 0xDA, 0xDA, 0x6C, 0xDA, 0xDA, 0xDA, 0xDA, 0x82, 0x98,
382 /* 0x50 */ 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xAE, 0xDA, 0xDA, 0xDA, 0xC4, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA,
383 /* 0x60 */ 0xDA, 0x4B, 0xDA, 0xDA, 0xDA, 0x61, 0xDA, 0xDA, 0xDA, 0x77, 0xDA, 0xDA, 0xDA, 0xDA, 0x8D, 0xA3,
384 /* 0x70 */ 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xB9, 0xDA, 0xDA, 0xDA, 0xCF, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA,
386 /* Combining Diacritical Marks (0x0300 - 0x030A) */
387 /* 0 1 2 3 4 5 6 7 8 9 A */
389 /* 0x0300 */ 0xCB, 0xE7, 0xE5, 0xCC, '?', '?', '?', '?', 0x80, '?', 0x81,
392 /* 0x0300 */ 0x88, 0x87, 0x89, 0x8B, '?', '?', '?', '?', 0x8A, '?', 0x8C,
395 /* 0x0300 */ 0xE9, 0x83, 0xE6, '?', '?', '?', '?', '?', 0xE8, '?', '?',
398 /* 0x0300 */ 0x8F, 0x8E, 0x90, '?', '?', '?', '?', '?', 0x91, '?', '?',
401 /* 0x0300 */ 0xED, 0xEA, 0xEB, '?', '?', '?', '?', '?', 0xEC, '?', '?',
404 /* 0x0300 */ 0x93, 0x92, 0x94, '?', '?', '?', '?', '?', 0x95, '?', '?',
407 /* 0x0300 */ '?', '?', '?', 0x84, '?', '?', '?', '?', '?', '?', '?',
410 /* 0x0300 */ '?', '?', '?', 0x96, '?', '?', '?', '?', '?', '?', '?',
413 /* 0x0300 */ 0xF1, 0xEE, 0xEF, 0xCD, '?', '?', '?', '?', 0x85, '?', '?',
416 /* 0x0300 */ 0x98, 0x97, 0x99, 0x9B, '?', '?', '?', '?', 0x9A, '?', '?',
419 /* 0x0300 */ 0xF4, 0xF2, 0xF3, '?', '?', '?', '?', '?', 0x86, '?', '?',
422 /* 0x0300 */ 0x9D, 0x9C, 0x9E, '?', '?', '?', '?', '?', 0x9F, '?', '?',
425 /* 0x0300 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xD9, '?', '?',
428 /* 0x0300 */ '?', '?', '?', '?', '?', '?', '?', '?', 0xD8, '?', '?',
431 /* 0x0300 */ '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?'
436 * Convert Unicode string into HFS MacRoman encoding
438 * Assumes Unicode input is fully decomposed
440 static int unicode_to_mac_roman(UniChar
*uni_str
, UInt32 unicodeChars
, Str31 hfs_str
)
448 OSErr result
= noErr
;
453 mask
= (UniChar
) 0xFF80;
456 inputChars
= unicodeChars
;
457 pascalChars
= prevChar
= 0;
464 * If its not 7-bit ascii, then we need to map it
468 switch (c
& 0xFF00) {
471 mc
= gLatin1Table
[lsb
- 0xA0];
475 if (lsb
>= 0xC0 && lsb
<= 0xDF)
476 mc
= gSpaceModsTable
[lsb
- 0xC0];
480 if (lsb
>= 0x10 && lsb
<= 0xAF)
481 mc
= gPunctTable
[lsb
- 0x10];
486 mc
= gMathTable
[lsb
];
491 if (prevChar
>= 'A' && prevChar
< 'z') {
492 mc
= gReverseCombTable
[gReverseCombTable
[prevChar
- 0x40] + lsb
];
493 --p
; /* backup over base char */
498 case 0x0327: /* combining cedilla */
501 else if (prevChar
== 'c')
505 --p
; /* backup over base char */
509 case 0x03A9: mc
= 0xBD; break; /* omega */
511 case 0x03C0: mc
= 0xB9; break; /* pi */
518 case 0x0131: mc
= 0xf5; break; /* dotless i */
520 case 0x0152: mc
= 0xce; break; /* OE */
522 case 0x0153: mc
= 0xcf; break; /* oe */
524 case 0x0192: mc
= 0xc4; break; /* Ä */
526 case 0x2122: mc
= 0xaa; break; /* TM */
528 case 0x25ca: mc
= 0xd7; break; /* diamond */
530 case 0xf8ff: mc
= 0xf0; break; /* apple logo */
532 case 0xfb01: mc
= 0xde; break; /* fi */
534 case 0xfb02: mc
= 0xdf; break; /* fl */
536 } /* end switch (c & 0xFF00) */
539 * If we have an unmapped character then we need to mangle the name...
542 result
= kTECUsedFallbacksStatus
;
551 if (pascalChars
>= 31)
560 hfs_str
[0] = pascalChars
;
563 result
= ENAMETOOLONG
; /* ran out of room! */
569 static UniChar gHiBitBaseUnicode
[128] = {
570 /* 0x80 */ 0x0041, 0x0041, 0x0043, 0x0045, 0x004e, 0x004f, 0x0055, 0x0061,
571 /* 0x88 */ 0x0061, 0x0061, 0x0061, 0x0061, 0x0061, 0x0063, 0x0065, 0x0065,
572 /* 0x90 */ 0x0065, 0x0065, 0x0069, 0x0069, 0x0069, 0x0069, 0x006e, 0x006f,
573 /* 0x98 */ 0x006f, 0x006f, 0x006f, 0x006f, 0x0075, 0x0075, 0x0075, 0x0075,
574 /* 0xa0 */ 0x2020, 0x00b0, 0x00a2, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df,
575 /* 0xa8 */ 0x00ae, 0x00a9, 0x2122, 0x00b4, 0x00a8, 0x2260, 0x00c6, 0x00d8,
576 /* 0xb0 */ 0x221e, 0x00b1, 0x2264, 0x2265, 0x00a5, 0x00b5, 0x2202, 0x2211,
577 /* 0xb8 */ 0x220f, 0x03c0, 0x222b, 0x00aa, 0x00ba, 0x03a9, 0x00e6, 0x00f8,
578 /* 0xc0 */ 0x00bf, 0x00a1, 0x00ac, 0x221a, 0x0192, 0x2248, 0x2206, 0x00ab,
579 /* 0xc8 */ 0x00bb, 0x2026, 0x00a0, 0x0041, 0x0041, 0x004f, 0x0152, 0x0153,
580 /* 0xd0 */ 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca,
581 /* 0xd8 */ 0x0079, 0x0059, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
582 /* 0xe0 */ 0x2021, 0x00b7, 0x201a, 0x201e, 0x2030, 0x0041, 0x0045, 0x0041,
583 /* 0xe8 */ 0x0045, 0x0045, 0x0049, 0x0049, 0x0049, 0x0049, 0x004f, 0x004f,
584 /* 0xf0 */ 0xf8ff, 0x004f, 0x0055, 0x0055, 0x0055, 0x0131, 0x02c6, 0x02dc,
585 /* 0xf8 */ 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7
588 static UniChar gHiBitCombUnicode
[128] = {
589 /* 0x80 */ 0x0308, 0x030a, 0x0327, 0x0301, 0x0303, 0x0308, 0x0308, 0x0301,
590 /* 0x88 */ 0x0300, 0x0302, 0x0308, 0x0303, 0x030a, 0x0327, 0x0301, 0x0300,
591 /* 0x90 */ 0x0302, 0x0308, 0x0301, 0x0300, 0x0302, 0x0308, 0x0303, 0x0301,
592 /* 0x98 */ 0x0300, 0x0302, 0x0308, 0x0303, 0x0301, 0x0300, 0x0302, 0x0308,
593 /* 0xa0 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
594 /* 0xa8 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
595 /* 0xb0 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
596 /* 0xb8 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
597 /* 0xc0 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
598 /* 0xc8 */ 0x0000, 0x0000, 0x0000, 0x0300, 0x0303, 0x0303, 0x0000, 0x0000,
599 /* 0xd0 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
600 /* 0xd8 */ 0x0308, 0x0308, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
601 /* 0xe0 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0302, 0x0302, 0x0301,
602 /* 0xe8 */ 0x0308, 0x0300, 0x0301, 0x0302, 0x0308, 0x0300, 0x0301, 0x0302,
603 /* 0xf0 */ 0x0000, 0x0300, 0x0301, 0x0302, 0x0300, 0x0000, 0x0000, 0x0000,
604 /* 0xf8 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
609 * Convert HFS MacRoman encoded string into Unicode
611 * Unicode output is fully decomposed
614 mac_roman_to_unicode(Str31 hfs_str
, UniChar
*uni_str
,
615 UInt32 maxCharLen
, UInt32
*unicodeChars
)
625 *unicodeChars
= pascalChars
= *(p
++); /* pick up length byte */
627 while (pascalChars
--) {
630 if ( (SInt8
) c
>= 0 ) { /* check if seven bit ascii */
631 *(u
++) = (UniChar
) c
; /* just pad high byte with zero */
632 } else { /* its a hi bit character */
636 *(u
++) = uc
= gHiBitBaseUnicode
[c
];
639 * if the unicode character we get back is an alpha char
640 * then we must have an additional combining character
642 if ((uc
<= (UniChar
) 'z') && (uc
>= (UniChar
) 'A')) {
643 *(u
++) = gHiBitCombUnicode
[c
];