From 40767598901ddaa11f5ac279e6e5775eed6ceedb Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Mon, 23 Oct 2006 23:01:47 +0300 Subject: [PATCH] Bug 821: With CONFIG_UTF8 and UTF-8 I/O, form_state.value is in UTF-8. That is even if the document and the terminal have some other charset. --- src/viewer/text/form.c | 31 +++++++++++++++++-------------- src/viewer/text/link.c | 4 +++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index 5f28cbc6..0695874b 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -1744,26 +1744,29 @@ field_op(struct session *ses, struct document_view *doc_view, } #ifdef CONFIG_UTF8 - { - /* The charset of the terminal; we assume - * fs->value is in this charset. - * (Is that OK?) */ + if (ses->tab->term->utf8) { + /* fs->value is in UTF-8 regardless of + * the charset of the terminal. */ + text = encode_utf8(get_kbd_key(ev)); + } else { + /* fs->value is in the charset of the + * terminal. */ int cp = get_opt_codepage_tree(ses->tab->term->spec, "charset"); text = u2cp_no_nbsp(get_kbd_key(ev), cp); - length = strlen(text); - - if (strlen(fs->value) + length > fc->maxlength - || !insert_in_string(&fs->value, fs->state, text, length)) { - status = FRAME_EVENT_OK; - break; - } + } + length = strlen(text); - fs->state += length; - if (fc->type == FC_TEXTAREA) - fs->state_cell = 0; + if (strlen(fs->value) + length > fc->maxlength + || !insert_in_string(&fs->value, fs->state, text, length)) { + status = FRAME_EVENT_OK; + break; } + + fs->state += length; + if (fc->type == FC_TEXTAREA) + fs->state_cell = 0; #else fs->value[fs->state++] = get_kbd_key(ev); #endif /* CONFIG_UTF8 */ diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 399c07c1..40e65e03 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -115,7 +115,9 @@ get_link_cursor_offset(struct document_view *doc_view, struct link *link) struct form_control *fc; struct form_state *fs; #ifdef CONFIG_UTF8 - int utf8 = doc_view->document->options.utf8; + /* The encoding of form fields depends on the terminal, + * rather than on the document. */ + int utf8 = doc_view->session->tab->term->utf8; #endif /* CONFIG_UTF8 */ switch (link->type) { -- 2.11.4.GIT