1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[document] Try to set system charset.

This commit is contained in:
Witold Filipczyk 2022-11-10 13:25:37 +01:00
parent 2fcf64e9bb
commit f1f18ace45
2 changed files with 11 additions and 2 deletions

View File

@ -803,7 +803,7 @@ document_parse(struct document *document)
add_bytes_to_string(&str, f->data, f->length); add_bytes_to_string(&str, f->data, f->length);
// Parse HTML and create a DOM tree // Parse HTML and create a DOM tree
xmlDoc* doc = htmlReadDoc((xmlChar*)str.source, NULL, get_cp_mime_name(document->cp), xmlDoc* doc = htmlReadDoc((xmlChar*)str.source, NULL, NULL,
HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING); HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
// Encapsulate raw libxml document in a libxml++ wrapper // Encapsulate raw libxml document in a libxml++ wrapper
xmlpp::Document *docu = new xmlpp::Document(doc); xmlpp::Document *docu = new xmlpp::Document(doc);

View File

@ -18,6 +18,7 @@
#include "elinks.h" #include "elinks.h"
#include "config/options.h" #include "config/options.h"
#include "intl/charsets.h"
#include "osdep/osdep.h" #include "osdep/osdep.h"
#include "protocol/common.h" #include "protocol/common.h"
#include "protocol/protocol.h" #include "protocol/protocol.h"
@ -51,6 +52,7 @@ init_directory_listing(struct string *page, struct uri *uri)
struct string location = NULL_STRING; struct string location = NULL_STRING;
const char *info; const char *info;
int local = (uri->protocol == PROTOCOL_FILE); int local = (uri->protocol == PROTOCOL_FILE);
char *charset = straconcat("<meta charset=\"", get_cp_mime_name(get_cp_index("System")), "\"/>", (char *) NULL);
if (!init_string(page) if (!init_string(page)
|| !init_string(&dirpath) || !init_string(&dirpath)
@ -73,7 +75,13 @@ init_directory_listing(struct string *page, struct uri *uri)
if (!local && !add_char_to_string(&location, '/')) if (!local && !add_char_to_string(&location, '/'))
goto out_of_memory; goto out_of_memory;
if (!add_to_string(page, "<html>\n<head><title>")) if (!add_to_string(page, "<html>\n<head>"))
goto out_of_memory;
if (!add_to_string(page, charset))
goto out_of_memory;
if (!add_to_string(page, "<title>"))
goto out_of_memory; goto out_of_memory;
if (!local && !add_html_to_string(page, location.source, location.length)) if (!local && !add_html_to_string(page, location.source, location.length))
@ -150,6 +158,7 @@ out_of_memory:
done_string(&dirpath); done_string(&dirpath);
done_string(&decoded); done_string(&decoded);
done_string(&location); done_string(&location);
mem_free_if(charset);
return page->length > 0 return page->length > 0
? connection_state(S_OK) ? connection_state(S_OK)