[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/mac.c
From: |
YAMAMOTO Mitsuharu |
Subject: |
[Emacs-diffs] Changes to emacs/src/mac.c |
Date: |
Fri, 15 Apr 2005 23:03:04 -0400 |
Index: emacs/src/mac.c
diff -c emacs/src/mac.c:1.32 emacs/src/mac.c:1.33
*** emacs/src/mac.c:1.32 Thu Apr 14 09:25:01 2005
--- emacs/src/mac.c Sat Apr 16 03:03:02 2005
***************
*** 31,36 ****
--- 31,38 ----
#include "sysselect.h"
#include "systime.h"
#include "blockinput.h"
+ #include "charset.h"
+ #include "coding.h"
#include "macterm.h"
***************
*** 265,271 ****
#if TARGET_API_MAC_CARBON
static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata;
static Lisp_Object Qarray, Qdictionary;
- extern Lisp_Object Qutf_8;
#define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0)
struct cfdict_context
--- 267,272 ----
***************
*** 274,280 ****
int with_tag, hash_bound;
};
! /* C string to CFString. */
CFStringRef
cfstring_create_with_utf8_cstring (c_str)
--- 275,281 ----
int with_tag, hash_bound;
};
! /* C string to CFString. */
CFStringRef
cfstring_create_with_utf8_cstring (c_str)
***************
*** 291,296 ****
--- 292,328 ----
}
+ /* Lisp string to CFString. */
+
+ CFStringRef
+ cfstring_create_with_string (s)
+ Lisp_Object s;
+ {
+ CFStringRef string = NULL;
+
+ if (STRING_MULTIBYTE (s))
+ {
+ char *p, *end = SDATA (s) + SBYTES (s);
+
+ for (p = SDATA (s); p < end; p++)
+ if (!isascii (*p))
+ {
+ s = ENCODE_UTF_8 (s);
+ break;
+ }
+ string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
+ kCFStringEncodingUTF8, false);
+ }
+
+ if (string == NULL)
+ /* Failed to interpret as UTF 8. Fall back on Mac Roman. */
+ string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
+ kCFStringEncodingMacRoman, false);
+
+ return string;
+ }
+
+
/* From CFData to a lisp string. Always returns a unibyte string. */
Lisp_Object
***************
*** 3711,3721 ****
app_id = kCFPreferencesCurrentApplication;
if (!NILP (application))
{
! app_id = cfstring_create_with_utf8_cstring (SDATA (application));
if (app_id == NULL)
goto out;
}
! key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key)));
if (key_str == NULL)
goto out;
app_plist = CFPreferencesCopyAppValue (key_str, app_id);
--- 3743,3753 ----
app_id = kCFPreferencesCurrentApplication;
if (!NILP (application))
{
! app_id = cfstring_create_with_string (application);
if (app_id == NULL)
goto out;
}
! key_str = cfstring_create_with_string (XCAR (key));
if (key_str == NULL)
goto out;
app_plist = CFPreferencesCopyAppValue (key_str, app_id);
***************
*** 3728,3734 ****
{
if (CFGetTypeID (plist) != CFDictionaryGetTypeID ())
break;
! key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key)));
if (key_str == NULL)
goto out;
plist = CFDictionaryGetValue (plist, key_str);
--- 3760,3766 ----
{
if (CFGetTypeID (plist) != CFDictionaryGetTypeID ())
break;
! key_str = cfstring_create_with_string (XCAR (key));
if (key_str == NULL)
goto out;
plist = CFDictionaryGetValue (plist, key_str);