diff --git a/src/dialogs/download.c b/src/dialogs/download.c index cd375d943..722c2af5b 100644 --- a/src/dialogs/download.c +++ b/src/dialogs/download.c @@ -145,7 +145,12 @@ download_dialog_layouter(struct dialog_data *dlg_data) mem_free(msg); return; } - decode_uri_for_display(url); +#ifdef CONFIG_UTF_8 + if (term->utf8) + decode_uri(url); + else +#endif /* CONFIG_UTF_8 */ + decode_uri_for_display(url); url_len = strlen(url); if (show_meter) { @@ -296,7 +301,14 @@ get_file_download_text(struct listbox_item *item, struct terminal *term) unsigned char *uristring; uristring = get_uri_string(file_download->uri, URI_PUBLIC); - if (uristring) decode_uri_for_display(uristring); + if (uristring) { +#ifdef CONFIG_UTF_8 + if (term->utf8) + decode_uri(uristring); + else +#endif /* CONFIG_UTF_8 */ + decode_uri_for_display(uristring); + } return uristring; } diff --git a/src/dialogs/menu.c b/src/dialogs/menu.c index 5eff89c35..b23c58a03 100644 --- a/src/dialogs/menu.c +++ b/src/dialogs/menu.c @@ -578,7 +578,12 @@ query_file(struct session *ses, struct uri *uri, void *data, add_mime_filename_to_string(&def, uri); /* Remove the %-ugliness for display */ - decode_uri_string_for_display(&def); +#ifdef CONFIG_UTF_8 + if (ses->tab->term->utf8) + decode_uri_string(&def); + else +#endif /* CONFIG_UTF_8 */ + decode_uri_string_for_display(&def); if (interactive) { input_dialog(ses->tab->term, NULL, diff --git a/src/dialogs/status.c b/src/dialogs/status.c index ac3f5b0f6..24424931c 100644 --- a/src/dialogs/status.c +++ b/src/dialogs/status.c @@ -142,15 +142,8 @@ get_current_link_info_and_title(struct session *ses, link_title = get_current_link_title(doc_view); if (link_title) { - unsigned char *src; - assert(*link_title); - /* Remove illicit chars. */ - for (src = link_title; *src; src++) - if (!isprint(*src) || iscntrl(*src)) - *src = '*'; - ret = straconcat(link_info, " - ", link_title, NULL); mem_free(link_info); mem_free(link_title); diff --git a/src/document/renderer.c b/src/document/renderer.c index 2af18ed6d..54035de0a 100644 --- a/src/document/renderer.c +++ b/src/document/renderer.c @@ -345,8 +345,14 @@ render_document(struct view_state *vs, struct document_view *doc_view, } document->title = get_uri_string(document->uri, components); - if (document->title) - decode_uri_for_display(document->title); + if (document->title) { +#ifdef CONFIG_UTF_8 + if (doc_view->document->options.utf8) + decode_uri(document->title); + else +#endif /* CONFIG_UTF_8 */ + decode_uri_for_display(document->title); + } } #ifdef CONFIG_CSS diff --git a/src/protocol/bittorrent/dialogs.c b/src/protocol/bittorrent/dialogs.c index 688a4727e..7a29ddb86 100644 --- a/src/protocol/bittorrent/dialogs.c +++ b/src/protocol/bittorrent/dialogs.c @@ -574,7 +574,12 @@ bittorrent_message_dialog(struct session *ses, void *data) uristring = get_uri_string(message->uri, URI_PUBLIC); if (uristring) { - decode_uri_for_display(uristring); +#ifdef CONFIG_UTF_8 + if (ses->tab->term->utf8) + decode_uri(uristring); + else +#endif /* CONFIG_UTF_8 */ + decode_uri_for_display(uristring); add_format_to_string(&string, _("Unable to retrieve %s", ses->tab->term), uristring); @@ -719,7 +724,12 @@ bittorrent_query_callback(void *data, enum connection_state state, /* Let's make the filename pretty for display & save */ /* TODO: The filename can be the empty string here. See bug 396. */ - decode_uri_string_for_display(&filename); +#ifdef CONFIG_UTF_8 + if (term->utf8) + decode_uri_string(&filename); + else +#endif /* CONFIG_UTF_8 */ + decode_uri_string_for_display(&filename); } add_format_to_string(&msg, diff --git a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c index 2ba57657d..12b779e6b 100644 --- a/src/protocol/gopher/gopher.c +++ b/src/protocol/gopher/gopher.c @@ -649,6 +649,10 @@ init_gopher_index_cache_entry(struct connection *conn) return S_OUT_OF_MEM; where = get_uri_string(conn->uri, URI_PUBLIC); + + /* TODO: Use different function when using UTF-8 + * in terminal (decode_uri_for_display replaces + * bytes of UTF-8 characters width '*'). */ if (where) decode_uri_for_display(where); add_format_to_string(&buffer, diff --git a/src/session/download.c b/src/session/download.c index 3ab40e13d..058e710f7 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -1048,7 +1048,12 @@ do_type_query(struct type_query *type_query, unsigned char *ct, struct mime_hand /* Let's make the filename pretty for display & save */ /* TODO: The filename can be the empty string here. See bug 396. */ - decode_uri_string_for_display(&filename); +#ifdef CONFIG_UTF_8 + if (term->utf8) + decode_uri_string(&filename); + else +#endif /* CONFIG_UTF_8 */ + decode_uri_string_for_display(&filename); } text = get_dialog_offset(dlg, TYPE_QUERY_WIDGETS_COUNT); diff --git a/src/session/session.c b/src/session/session.c index d79b80f47..797cfd236 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -268,7 +268,12 @@ print_error_dialog(struct session *ses, enum connection_state state, uristring = uri ? get_uri_string(uri, URI_PUBLIC) : NULL; if (uristring) { - decode_uri_for_display(uristring); +#ifdef CONFIG_UTF_8 + if (ses->tab->term->utf8) + decode_uri(uristring); + else +#endif /* CONFIG_UTF_8 */ + decode_uri_for_display(uristring); add_format_to_string(&msg, _("Unable to retrieve %s", ses->tab->term), uristring); diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 688906896..a678ceaf0 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -1347,7 +1347,7 @@ end: do_menu(term, mi, ses, 1); } -/* Return current link's title. Pretty trivial. */ +/* Return current link's title. */ unsigned char * get_current_link_title(struct document_view *doc_view) { @@ -1361,7 +1361,29 @@ get_current_link_title(struct document_view *doc_view) link = get_current_link(doc_view); - return (link && link->title && *link->title) ? stracpy(link->title) : NULL; + if (link && link->title && *link->title) { + unsigned char *link_title, *src; + struct conv_table *convert_table; + + convert_table = get_translation_table(doc_view->document->cp, + doc_view->document->options.cp); + + link_title = convert_string(convert_table, link->title, + strlen(link->title), + doc_view->document->options.cp, + CSM_DEFAULT, NULL, NULL, NULL); + /* Remove illicit chars. */ +#ifdef CONFIG_UTF_8 + if (link_title && !doc_view->document->options.utf8) +#endif /* CONFIG_UTF_8 */ + for (src = link_title; *src; src++) + if (!isprint(*src) || iscntrl(*src)) + *src = '*'; + + return link_title; + } + + return NULL; } unsigned char * @@ -1406,7 +1428,12 @@ get_current_link_info(struct session *ses, struct document_view *doc_view) add_char_to_string(&str, ')'); } - decode_uri_string_for_display(&str); +#ifdef CONFIG_UTF_8 + if (term->utf8) + decode_uri_string(&str); + else +#endif /* CONFIG_UTF_8 */ + decode_uri_string_for_display(&str); return str.source; } diff --git a/src/viewer/text/link.h b/src/viewer/text/link.h index 6014be88b..39f431673 100644 --- a/src/viewer/text/link.h +++ b/src/viewer/text/link.h @@ -11,6 +11,7 @@ struct session; struct term_event; struct terminal; struct uri; +struct conv_table; void set_link(struct document_view *doc_view); void free_link(struct document_view *doc_view);