diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2006-11-04 12:38:24 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2006-11-04 12:38:24 +0000 |
commit | a1f291383f719852dd11efa3877599c7dae5f95b (patch) | |
tree | 0933b1b2c5779be62aea6c60409dff8a24d1d69e /riscos/query.c | |
parent | 8cab28a8c29d1a469db728775aff2b6de3a25acb (diff) | |
download | netsurf-a1f291383f719852dd11efa3877599c7dae5f95b.tar.gz netsurf-a1f291383f719852dd11efa3877599c7dae5f95b.tar.bz2 |
Convert query button text to local encoding correctly
svn path=/trunk/netsurf/; revision=3025
Diffstat (limited to 'riscos/query.c')
-rw-r--r-- | riscos/query.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/riscos/query.c b/riscos/query.c index 8cf1c7444..e619f88a0 100644 --- a/riscos/query.c +++ b/riscos/query.c @@ -15,6 +15,7 @@ #include "netsurf/riscos/wimp_event.h" #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" +#include "netsurf/utils/utf8.h" #include "netsurf/utils/utils.h" #define ICON_QUERY_MESSAGE 0 @@ -103,6 +104,8 @@ query_id query_user(const char *query, const char *detail, int width; int len; int x; + char *local_text = NULL; + utf8_convert_ret err; qw = malloc(sizeof(struct gui_query_window)); if (!qw) { @@ -122,11 +125,23 @@ query_id query_user(const char *query, const char *detail, if (!no) no = messages_get("No"); /* set the text of the 'Yes' button and size accordingly */ + err = utf8_to_local_encoding(yes, 0, &local_text); + if (err != UTF8_CONVERT_OK) { + assert(err != UTF8_CONVERT_BADENC); + LOG(("utf8_to_local_encoding_failed")); + local_text = NULL; + } + icn = &query_template->icons[ICON_QUERY_YES]; - len = strnlen(yes, icn->data.indirected_text.size - 1); - memcpy(icn->data.indirected_text.text, yes, len); + len = strnlen(local_text ? local_text : yes, + icn->data.indirected_text.size - 1); + memcpy(icn->data.indirected_text.text, + local_text ? local_text: yes, len); icn->data.indirected_text.text[len] = '\0'; + free(local_text); + local_text = NULL; + error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width); if (error) { LOG(("xwimptextop_string_width: 0x%x:%s", @@ -140,11 +155,23 @@ query_id query_user(const char *query, const char *detail, icn->extent.x0 = x = icn->extent.x1 - width; /* set the text of the 'No' button and size accordingly */ + err = utf8_to_local_encoding(no, 0, &local_text); + if (err != UTF8_CONVERT_OK) { + assert(err != UTF8_CONVERT_BADENC); + LOG(("utf8_to_local_encoding_failed")); + local_text = NULL; + } + icn = &query_template->icons[ICON_QUERY_NO]; - len = strnlen(no, icn->data.indirected_text.size - 1); - memcpy(icn->data.indirected_text.text, no, len); + len = strnlen(local_text ? local_text : no, + icn->data.indirected_text.size - 1); + memcpy(icn->data.indirected_text.text, + local_text ? local_text : no, len); icn->data.indirected_text.text[len] = '\0'; + free(local_text); + local_text = NULL; + if (!query_no_width) query_no_width = icn->extent.x1 - icn->extent.x0; icn->extent.x1 = x - 16; error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width); |