From abc7a71117e4ae03f9b7146ce3f299a4b931b1ef Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 18 Jul 2015 20:12:01 +0100 Subject: [PATCH] Pass the URL bar contents back as UTF-8. --- riscos/gui/url_bar.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/riscos/gui/url_bar.c b/riscos/gui/url_bar.c index 5eccd602e..a25ea8748 100644 --- a/riscos/gui/url_bar.c +++ b/riscos/gui/url_bar.c @@ -83,6 +83,7 @@ struct url_bar { wimp_i text_icon; char *text_buffer; size_t text_size; + char *text_buffer_utf8; wimp_i suggest_icon; int suggest_x, suggest_y; @@ -508,6 +509,9 @@ void ro_gui_url_bar_destroy(struct url_bar *url_bar) if (url_bar == NULL) return; + if (url_bar->text_buffer_utf8 != NULL) + free(url_bar->text_buffer_utf8); + free(url_bar); } @@ -1073,6 +1077,15 @@ const char *ro_gui_url_bar_get_url(struct url_bar *url_bar) if (url_bar == NULL) return NULL; + if (url_bar->text_buffer_utf8 != NULL) { + free(url_bar->text_buffer_utf8); + url_bar->text_buffer_utf8 = NULL; + } + + if (utf8_from_local_encoding(url_bar->text_buffer, 0, &url_bar->text_buffer_utf8) == NSERROR_OK) { + return (const char *) url_bar->text_buffer_utf8; + } + return (const char *) url_bar->text_buffer; }