summaryrefslogtreecommitdiff
path: root/riscos/help.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2005-07-16 14:35:25 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2005-07-16 14:35:25 +0000
commitf4ecaaed31db0aa5d71c05dd3f04dc2833ad29fe (patch)
tree362b09da27833d63b3ae7b8d9fd14a4b56e92243 /riscos/help.c
parent81a39c30755e9bb61a10a0edb16fec8996100024 (diff)
downloadnetsurf-f4ecaaed31db0aa5d71c05dd3f04dc2833ad29fe.tar.gz
netsurf-f4ecaaed31db0aa5d71c05dd3f04dc2833ad29fe.tar.bz2
[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
Diffstat (limited to 'riscos/help.c')
-rw-r--r--riscos/help.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/riscos/help.c b/riscos/help.c
index bc5494c45..50f6912ce 100644
--- a/riscos/help.c
+++ b/riscos/help.c
@@ -9,6 +9,7 @@
* Interactive help (implementation).
*/
+#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include "oslib/help.h"
@@ -24,6 +25,7 @@
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/log.h"
+#include "netsurf/utils/utf8.h"
#include "netsurf/utils/utils.h"
@@ -158,7 +160,7 @@ void ro_gui_interactive_help_request(wimp_message *message) {
sprintf(message_token, "HelpToolbar%i", (int)icon);
} else if ((g = ro_gui_status_lookup(window)) != NULL)
sprintf(message_token, "HelpStatus%i", (int)icon);
-
+
/* change toolbars to editors where appropriate */
if ((toolbar) && (toolbar->editor))
sprintf(message_token, "HelpEditToolbar%i", (int)icon);
@@ -233,7 +235,9 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message,
const char *translated_token;
help_full_message_reply *reply;
char *base_token;
+ char *local_token;
os_error *error;
+ utf8_convert_ret err;
/* start off with an empty reply */
reply = (help_full_message_reply *)message;
@@ -260,8 +264,20 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message,
/* copy our message string */
if (translated_token != token) {
- reply->reply[235] = 0;
- strncpy(reply->reply, translated_token, 235);
+ /* convert to local encoding */
+ err = utf8_to_local_encoding(translated_token, 0,
+ &local_token);
+ if (err != UTF8_CONVERT_OK) {
+ /* badenc should never happen */
+ assert(err != UTF8_CONVERT_BADENC);
+ /* simply use UTF-8 string */
+ strncpy(reply->reply, translated_token, 235);
+ }
+ else {
+ strncpy(reply->reply, local_token, 235);
+ free(local_token);
+ }
+ reply->reply[235] = '\0';
}
/* broadcast the help reply */
@@ -303,7 +319,7 @@ bool ro_gui_interactive_help_available(void) {
error->errnum, error->errmess));
warn_user("MiscError", error->errmess);
}
-
+
/* we can't just use strcmp due to string termination issues */
if (!strncmp(task.name, "Help", 4) &&
(task.name[4] < 32))