1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

Bug 827: Force UTF-8 I/O on if the UTF-8 charset is selected.

This commit is contained in:
Kalle Olavi Niemitalo 2006-12-09 21:13:13 +02:00 committed by Kalle Olavi Niemitalo
parent efc202b4ea
commit 9efc661384
4 changed files with 23 additions and 11 deletions

View File

@ -887,8 +887,12 @@ static struct option_info config_options_info[] = {
INIT_OPT_BOOL("terminal._template_", N_("UTF-8 I/O"), INIT_OPT_BOOL("terminal._template_", N_("UTF-8 I/O"),
"utf_8_io", 0, 0, "utf_8_io", 0, 0,
N_("Enable I/O in UTF8 for Unicode terminals. Note that currently,\n" N_("Enable I/O in UTF-8 for Unicode terminals. Note that currently,\n"
"only the subset of UTF8 according to terminal codepage is used.")), "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"), INIT_OPT_BOOL("terminal._template_", N_("Restrict frames in cp850/852"),
"restrict_852", 0, 0, "restrict_852", 0, 0,

View File

@ -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 /* Probably not best place for set this. But now we finally have
* term->spec and term->utf8 should be set before decode session info. * term->spec and term->utf8 should be set before decode session info.
* --Scrool */ * --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 */ #endif /* CONFIG_UTF8 */
} }
@ -297,15 +301,14 @@ handle_interlink_event(struct terminal *term, struct interlink_event *ilev)
/* Character Conversions. */ /* Character Conversions. */
#ifdef CONFIG_UTF8 #ifdef CONFIG_UTF8
/* struct term_event_keyboard carries UCS-4. /* struct term_event_keyboard carries UCS-4.
* - If the "utf_8_io" option (i.e. term->utf8) is * - If the "utf_8_io" option is true or the "charset"
* true or the "charset" option refers to UTF-8, * option refers to UTF-8, then term->utf8 is true,
* then handle_interlink_event() converts from UTF-8 * and handle_interlink_event() converts from UTF-8
* to UCS-4. * to UCS-4.
* - Otherwise, handle_interlink_event() converts from * - Otherwise, handle_interlink_event() converts from
* the codepage specified with the "charset" option * the codepage specified with the "charset" option
* to UCS-4. */ * to UCS-4. */
utf8_io = term->utf8 utf8_io = term->utf8;
|| is_cp_utf8(get_opt_codepage_tree(term->spec, "charset"));
#else #else
/* struct term_event_keyboard carries bytes in the /* struct term_event_keyboard carries bytes in the
* charset of the terminal. * charset of the terminal.

View File

@ -132,7 +132,7 @@ struct screen_driver {
unsigned int transparent:1; unsigned int transparent:1;
#ifdef CONFIG_UTF8 #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; unsigned int utf8:1;
#endif /* CONFIG_UTF8 */ #endif /* CONFIG_UTF8 */
@ -241,7 +241,11 @@ static void
update_screen_driver(struct screen_driver *driver, struct option *term_spec) update_screen_driver(struct screen_driver *driver, struct option *term_spec)
{ {
#ifdef CONFIG_UTF8 #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 #else
int utf8_io = get_opt_bool_tree(term_spec, "utf_8_io"); int utf8_io = get_opt_bool_tree(term_spec, "utf_8_io");
#endif /* CONFIG_UTF8 */ #endif /* CONFIG_UTF8 */

View File

@ -127,7 +127,8 @@ struct terminal {
unsigned int master:1; unsigned int master:1;
#ifdef CONFIG_UTF8 #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; unsigned int utf8:1;
#endif /* CONFIG_UTF8 */ #endif /* CONFIG_UTF8 */