From f86bdc80c496aee7c29675f05d3690cf2c128091 Mon Sep 17 00:00:00 2001 From: Steven Tamm Date: Wed, 1 Dec 2004 15:51:22 +0000 Subject: [PATCH] * macmenu.c (add_menu_item): Fallback on MacRoman if encoding menu text as UTF8 fails. --- src/ChangeLog | 5 +++++ src/macmenu.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 0eca89ab0c6..2faf38841aa 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-12-01 YAMAMOTO Mitsuharu + + * macmenu.c (add_menu_item): Fallback on MacRoman if encoding + menu text as UTF8 fails. + 2004-12-01 Kim F. Storm * alloc.c: Add commentary for last change. diff --git a/src/macmenu.c b/src/macmenu.c index 007fab15eab..af24cfe237c 100644 --- a/src/macmenu.c +++ b/src/macmenu.c @@ -2267,6 +2267,14 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu, CFStringRef string = CFStringCreateWithCString (NULL, item_name, kCFStringEncodingUTF8); + if (string == NULL) + { + /* Failed to interpret as UTF8. Fall back to Mac Roman. + Maybe wv->name is corrupted? */ + string = CFStringCreateWithCString (NULL, item_name, + kCFStringEncodingMacRoman); + } + SetMenuItemTextWithCFString (menu, pos, string); CFRelease (string); } -- 2.39.5