3411 |
} |
} |
3412 |
|
|
3413 |
/* Convert a lisp string to the 4 byte character code. */ |
/* Convert a lisp string to the 4 byte character code. */ |
3414 |
|
|
3415 |
OSType |
OSType |
3416 |
mac_get_code_from_arg(Lisp_Object arg, OSType defCode) |
mac_get_code_from_arg(Lisp_Object arg, OSType defCode) |
3417 |
{ |
{ |
3419 |
if (NILP(arg)) |
if (NILP(arg)) |
3420 |
{ |
{ |
3421 |
result = defCode; |
result = defCode; |
3422 |
} |
} |
3423 |
else |
else |
3424 |
{ |
{ |
3425 |
/* check type string */ |
/* check type string */ |
3483 |
|
|
3484 |
status = FSpGetFInfo (&fss, &finder_info); |
status = FSpGetFInfo (&fss, &finder_info); |
3485 |
#endif |
#endif |
3486 |
if (status == noErr) |
if (status == noErr) |
3487 |
{ |
{ |
3488 |
#ifdef MAC_OSX |
#ifdef MAC_OSX |
3489 |
result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileCreator); |
result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileCreator); |
3538 |
|
|
3539 |
status = FSpGetFInfo (&fss, &finder_info); |
status = FSpGetFInfo (&fss, &finder_info); |
3540 |
#endif |
#endif |
3541 |
if (status == noErr) |
if (status == noErr) |
3542 |
{ |
{ |
3543 |
#ifdef MAC_OSX |
#ifdef MAC_OSX |
3544 |
result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileType); |
result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileType); |
3596 |
|
|
3597 |
status = FSpGetFInfo (&fss, &finder_info); |
status = FSpGetFInfo (&fss, &finder_info); |
3598 |
#endif |
#endif |
3599 |
if (status == noErr) |
if (status == noErr) |
3600 |
{ |
{ |
3601 |
#ifdef MAC_OSX |
#ifdef MAC_OSX |
3602 |
((FileInfo*)&catalogInfo.finderInfo)->fileCreator = cCode; |
((FileInfo*)&catalogInfo.finderInfo)->fileCreator = cCode; |
3656 |
|
|
3657 |
status = FSpGetFInfo (&fss, &finder_info); |
status = FSpGetFInfo (&fss, &finder_info); |
3658 |
#endif |
#endif |
3659 |
if (status == noErr) |
if (status == noErr) |
3660 |
{ |
{ |
3661 |
#ifdef MAC_OSX |
#ifdef MAC_OSX |
3662 |
((FileInfo*)&catalogInfo.finderInfo)->fileType = cCode; |
((FileInfo*)&catalogInfo.finderInfo)->fileType = cCode; |
3968 |
CFStringRef iana_name; |
CFStringRef iana_name; |
3969 |
CFStringEncoding encoding = kCFStringEncodingInvalidId; |
CFStringEncoding encoding = kCFStringEncodingInvalidId; |
3970 |
|
|
3971 |
|
if (NILP (obj)) |
3972 |
|
return kCFStringEncodingUnicode; |
3973 |
|
|
3974 |
if (INTEGERP (obj)) |
if (INTEGERP (obj)) |
3975 |
return XINT (obj); |
return XINT (obj); |
3976 |
|
|
3977 |
if (SYMBOLP (obj) && !NILP (obj) && !NILP (Fcoding_system_p (obj))) |
if (SYMBOLP (obj) && !NILP (Fcoding_system_p (obj))) |
3978 |
{ |
{ |
3979 |
Lisp_Object coding_spec, plist; |
Lisp_Object coding_spec, plist; |
3980 |
|
|
4118 |
doc: /* Convert STRING from SOURCE encoding to TARGET encoding. |
doc: /* Convert STRING from SOURCE encoding to TARGET encoding. |
4119 |
The conversion is performed using the converter provided by the system. |
The conversion is performed using the converter provided by the system. |
4120 |
Each encoding is specified by either a coding system symbol, a mime |
Each encoding is specified by either a coding system symbol, a mime |
4121 |
charset string, or an integer as a CFStringEncoding value. |
charset string, or an integer as a CFStringEncoding value. Nil for |
4122 |
|
encoding means UTF-16 in native byte order, no byte order marker. |
4123 |
On Mac OS X 10.2 and later, you can do Unicode Normalization by |
On Mac OS X 10.2 and later, you can do Unicode Normalization by |
4124 |
specifying the optional argument NORMALIZATION-FORM with a symbol NFD, |
specifying the optional argument NORMALIZATION-FORM with a symbol NFD, |
4125 |
NFKD, NFC, NFKC, HFS+D, or HFS+C. |
NFKD, NFC, NFKC, HFS+D, or HFS+C. |
4130 |
Lisp_Object result = Qnil; |
Lisp_Object result = Qnil; |
4131 |
CFStringEncoding src_encoding, tgt_encoding; |
CFStringEncoding src_encoding, tgt_encoding; |
4132 |
CFStringRef str = NULL; |
CFStringRef str = NULL; |
|
CFDataRef data = NULL; |
|
4133 |
|
|
4134 |
CHECK_STRING (string); |
CHECK_STRING (string); |
4135 |
if (!INTEGERP (source) && !STRINGP (source)) |
if (!INTEGERP (source) && !STRINGP (source)) |
4151 |
if (src_encoding != kCFStringEncodingInvalidId |
if (src_encoding != kCFStringEncodingInvalidId |
4152 |
&& tgt_encoding != kCFStringEncodingInvalidId) |
&& tgt_encoding != kCFStringEncodingInvalidId) |
4153 |
str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string), |
str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string), |
4154 |
src_encoding, true); |
src_encoding, !NILP (source)); |
4155 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
4156 |
if (str) |
if (str) |
4157 |
{ |
{ |
4163 |
#endif |
#endif |
4164 |
if (str) |
if (str) |
4165 |
{ |
{ |
4166 |
data = CFStringCreateExternalRepresentation (NULL, str, |
CFIndex str_len, buf_len; |
4167 |
tgt_encoding, '\0'); |
|
4168 |
|
str_len = CFStringGetLength (str); |
4169 |
|
if (CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0, |
4170 |
|
!NILP (target), NULL, 0, &buf_len) == str_len) |
4171 |
|
{ |
4172 |
|
result = make_uninit_string (buf_len); |
4173 |
|
CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0, |
4174 |
|
!NILP (target), SDATA (result), buf_len, NULL); |
4175 |
|
} |
4176 |
CFRelease (str); |
CFRelease (str); |
4177 |
} |
} |
|
if (data) |
|
|
{ |
|
|
result = cfdata_to_lisp (data); |
|
|
CFRelease (data); |
|
|
} |
|
4178 |
|
|
4179 |
UNBLOCK_INPUT; |
UNBLOCK_INPUT; |
4180 |
|
|