From f4ecaaed31db0aa5d71c05dd3f04dc2833ad29fe Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 16 Jul 2005 14:35:25 +0000 Subject: [project @ 2005-07-16 14:35:20 by jmb] - Convert Messages files to UTF-8 encoding. - Replace local_encoding_name() with platform specific utf8_[to,from]_local_encoding() functions - this allows mapping of 8bit characters 0x80->0x9f (inclusive). - All text that is rendered by the RISC OS Wimp is now converted to the system local encoding prior to display. - Lose the horrendous hack that was messages_get_key() - Menu text is now translated to system local encoding on the fly (if necessary) rather than at menu creation time. This allows the system alphabet to change under us and our menus remain usable. - The Languages menu now lists all languages that are present in the LangNames file. In the case of selecting the UI language, those languages which are not available are shaded. svn path=/import/netsurf/; revision=1796 --- riscos/download.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'riscos/download.c') diff --git a/riscos/download.c b/riscos/download.c index 3f64cd315..02c226c05 100644 --- a/riscos/download.c +++ b/riscos/download.c @@ -38,6 +38,7 @@ #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" #include "netsurf/utils/url.h" +#include "netsurf/utils/utf8.h" #include "netsurf/utils/utils.h" @@ -385,6 +386,8 @@ void ro_gui_download_update_status(struct gui_download_window *dw) float rate; os_error *error; int width; + char *local_status; + utf8_convert_ret err; gettimeofday(&t, 0); dt = (t.tv_sec + 0.000001 * t.tv_usec) - (dw->last_time.tv_sec + @@ -405,18 +408,47 @@ void ro_gui_download_update_status(struct gui_download_window *dw) left = (dw->total_size - dw->received) / rate; sprintf(time, "%u:%.2u", left / 60, left % 60); } - snprintf(dw->status, sizeof dw->status, + + /* convert to local encoding */ + err = utf8_to_local_encoding( + messages_get("Download"), 0, &local_status); + if (err != UTF8_CONVERT_OK) { + /* badenc should never happen */ + assert(err != UTF8_CONVERT_BADENC); + /* hide nomem error */ + snprintf(dw->status, sizeof dw->status, messages_get("Download"), received, total_size, speed, time); + } + else { + snprintf(dw->status, sizeof dw->status, + local_status, + received, total_size, speed, time); + free(local_status); + } f = (float) dw->received / (float) dw->total_size; width = download_progress_width * f; } else { left = t.tv_sec - dw->start_time.tv_sec; sprintf(time, "%u:%.2u", left / 60, left % 60); - snprintf(dw->status, sizeof dw->status, + + err = utf8_to_local_encoding( + messages_get("DownloadU"), 0, &local_status); + if (err != UTF8_CONVERT_OK) { + /* badenc should never happen */ + assert(err != UTF8_CONVERT_BADENC); + /* hide nomem error */ + snprintf(dw->status, sizeof dw->status, messages_get("DownloadU"), received, speed, time); + } + else { + snprintf(dw->status, sizeof dw->status, + local_status, + received, speed, time); + free(local_status); + } /* length unknown, stay at 0 til finished */ width = 0; @@ -428,9 +460,22 @@ void ro_gui_download_update_status(struct gui_download_window *dw) rate = (float) dw->received / (float) left; sprintf(time, "%u:%.2u", left / 60, left % 60); speed = human_friendly_bytesize(rate); - snprintf(dw->status, sizeof dw->status, + + err = utf8_to_local_encoding(messages_get("DownloadU"), 0, + &local_status); + if (err != UTF8_CONVERT_OK) { + /* badenc should never happen */ + assert(err != UTF8_CONVERT_BADENC); + /* hide nomem error */ + snprintf(dw->status, sizeof dw->status, messages_get("Downloaded"), total_size, speed, time); + } + else { + snprintf(dw->status, sizeof dw->status, local_status, + total_size, speed, time); + free(local_status); + } /* all done */ width = download_progress_width; -- cgit v1.2.3