From 9efc661384b2020fd71be93137522b6f071a0f04 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 9 Dec 2006 21:13:13 +0200 Subject: [PATCH] Bug 827: Force UTF-8 I/O on if the UTF-8 charset is selected. --- src/config/options.inc | 8 ++++++-- src/terminal/event.c | 15 +++++++++------ src/terminal/screen.c | 8 ++++++-- src/terminal/terminal.h | 3 ++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/config/options.inc b/src/config/options.inc index a78888bc..c2fae4c7 100644 --- a/src/config/options.inc +++ b/src/config/options.inc @@ -887,8 +887,12 @@ static struct option_info config_options_info[] = { INIT_OPT_BOOL("terminal._template_", N_("UTF-8 I/O"), "utf_8_io", 0, 0, - N_("Enable I/O in UTF8 for Unicode terminals. Note that currently,\n" - "only the subset of UTF8 according to terminal codepage is used.")), + N_("Enable I/O in UTF-8 for Unicode terminals. Note that currently,\n" + "only the subset of UTF-8 according to terminal codepage is used.\n" + "ELinks ignores this option if the terminal codepage is UTF-8.")), + /* When CONFIG_UTF8 is defined, any code that reads the "utf_8_io" + * option should also check whether the "codepage" option is UTF-8, + * and if so, behave as if "utf_8_io" were 1. */ INIT_OPT_BOOL("terminal._template_", N_("Restrict frames in cp850/852"), "restrict_852", 0, 0, diff --git a/src/terminal/event.c b/src/terminal/event.c index adbd2195..49913aab 100644 --- a/src/terminal/event.c +++ b/src/terminal/event.c @@ -182,7 +182,11 @@ check_terminal_name(struct terminal *term, struct terminal_info *info) /* Probably not best place for set this. But now we finally have * term->spec and term->utf8 should be set before decode session info. * --Scrool */ - term->utf8 = get_opt_bool_tree(term->spec, "utf_8_io"); + /* Force UTF-8 I/O if the UTF-8 charset is selected. Various + * places assume that the terminal's charset is unibyte if + * UTF-8 I/O is disabled. (bug 827) */ + term->utf8 = get_opt_bool_tree(term->spec, "utf_8_io") + || is_cp_utf8(get_opt_codepage_tree(term->spec, "charset")); #endif /* CONFIG_UTF8 */ } @@ -297,15 +301,14 @@ handle_interlink_event(struct terminal *term, struct interlink_event *ilev) /* Character Conversions. */ #ifdef CONFIG_UTF8 /* struct term_event_keyboard carries UCS-4. - * - If the "utf_8_io" option (i.e. term->utf8) is - * true or the "charset" option refers to UTF-8, - * then handle_interlink_event() converts from UTF-8 + * - If the "utf_8_io" option is true or the "charset" + * option refers to UTF-8, then term->utf8 is true, + * and handle_interlink_event() converts from UTF-8 * to UCS-4. * - Otherwise, handle_interlink_event() converts from * the codepage specified with the "charset" option * to UCS-4. */ - utf8_io = term->utf8 - || is_cp_utf8(get_opt_codepage_tree(term->spec, "charset")); + utf8_io = term->utf8; #else /* struct term_event_keyboard carries bytes in the * charset of the terminal. diff --git a/src/terminal/screen.c b/src/terminal/screen.c index 58181cff..1f5e0ca0 100644 --- a/src/terminal/screen.c +++ b/src/terminal/screen.c @@ -132,7 +132,7 @@ struct screen_driver { unsigned int transparent:1; #ifdef CONFIG_UTF8 - /* UTF-8 I/O */ + /* UTF-8 I/O. Forced on if the UTF-8 charset is selected. (bug 827) */ unsigned int utf8:1; #endif /* CONFIG_UTF8 */ @@ -241,7 +241,11 @@ static void update_screen_driver(struct screen_driver *driver, struct option *term_spec) { #ifdef CONFIG_UTF8 - driver->utf8 = get_opt_bool_tree(term_spec, "utf_8_io"); + /* Force UTF-8 I/O if the UTF-8 charset is selected. Various + * places assume that the terminal's charset is unibyte if + * UTF-8 I/O is disabled. (bug 827) */ + driver->utf8 = get_opt_bool_tree(term_spec, "utf_8_io") + || is_cp_utf8(get_opt_codepage_tree(term_spec, "charset")); #else int utf8_io = get_opt_bool_tree(term_spec, "utf_8_io"); #endif /* CONFIG_UTF8 */ diff --git a/src/terminal/terminal.h b/src/terminal/terminal.h index e04fb1e7..9a609aac 100644 --- a/src/terminal/terminal.h +++ b/src/terminal/terminal.h @@ -127,7 +127,8 @@ struct terminal { unsigned int master:1; #ifdef CONFIG_UTF8 - /* Indicates whether UTF-8 I/O is used */ + /* Indicates whether UTF-8 I/O is used. Forced on if the + * UTF-8 charset is selected. (bug 827) */ unsigned int utf8:1; #endif /* CONFIG_UTF8 */