Mercurial > emacs
diff src/mac.c @ 58752:4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
* image.c (image_load_quartz2d): Use
cfstring_create_with_utf8_cstring
* macmenu.c (add_menu_item): Use
cfstring_create_with_utf8_cstring
* macfns.c (x_set_name, x_set_title): Use
cfstring_create_with_utf8_cstring
(Fx_file_dialog): Use cfstring_create_with_utf8_cstring and use
constant CFRefs instead of creating them each time for labels.
* mac.c (cfstring_create_with_utf8_cstring): Added to prevent
crashes with invalid characters.
author | Steven Tamm <steventamm@mac.com> |
---|---|
date | Fri, 03 Dec 2004 17:00:11 +0000 |
parents | 0867872551d9 |
children | 9bde7721ad0f f2ebccfa87d4 |
line wrap: on
line diff
--- a/src/mac.c Fri Dec 03 11:30:11 2004 +0000 +++ b/src/mac.c Fri Dec 03 17:00:11 2004 +0000 @@ -262,6 +262,22 @@ return 1; } +#if TARGET_API_MAC_CARBON +CFStringRef +cfstring_create_with_utf8_cstring (c_str) + const char *c_str; +{ + CFStringRef str; + + str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingUTF8); + if (str == NULL) + /* Failed to interpret as UTF 8. Fall back on Mac Roman. */ + str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingMacRoman); + + return str; +} +#endif + #ifndef MAC_OSX /* The following functions with "sys_" prefix are stubs to Unix