mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[xml] Do not assume utf-8.
document_write4.html does not display utf-8
This commit is contained in:
parent
c9fe1bf546
commit
b9910df99d
@ -2585,6 +2585,7 @@ render_html_document(struct cache_entry *cached, struct document *document,
|
|||||||
char *end;
|
char *end;
|
||||||
struct string title;
|
struct string title;
|
||||||
struct string head;
|
struct string head;
|
||||||
|
int xml2;
|
||||||
|
|
||||||
assert(cached && document);
|
assert(cached && document);
|
||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
@ -2601,15 +2602,19 @@ render_html_document(struct cache_entry *cached, struct document *document,
|
|||||||
put_chars_conv, line_break,
|
put_chars_conv, line_break,
|
||||||
html_special);
|
html_special);
|
||||||
if (!html_context) return;
|
if (!html_context) return;
|
||||||
|
#ifdef CONFIG_ECMASCRIPT
|
||||||
|
xml2 = !!document->dom;
|
||||||
|
#else
|
||||||
|
xml2 = 0;
|
||||||
|
#endif
|
||||||
renderer_context.g_ctrl_num = 0;
|
renderer_context.g_ctrl_num = 0;
|
||||||
renderer_context.cached = cached;
|
renderer_context.cached = cached;
|
||||||
renderer_context.convert_table = get_convert_table(head.source,
|
renderer_context.convert_table = get_convert_table(head.source,
|
||||||
document->options.cp,
|
document->options.cp,
|
||||||
document->options.assume_cp,
|
xml2 ? get_cp_index("utf-8") : document->options.assume_cp,
|
||||||
&document->cp,
|
&document->cp,
|
||||||
&document->cp_status,
|
&document->cp_status,
|
||||||
document->options.hard_assume);
|
xml2 ? 1 : document->options.hard_assume);
|
||||||
#ifdef CONFIG_UTF8
|
#ifdef CONFIG_UTF8
|
||||||
html_context->options->utf8 = is_cp_utf8(document->options.cp);
|
html_context->options->utf8 = is_cp_utf8(document->options.cp);
|
||||||
#endif /* CONFIG_UTF8 */
|
#endif /* CONFIG_UTF8 */
|
||||||
|
@ -354,26 +354,9 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str
|
|||||||
if (!document->dom) {
|
if (!document->dom) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct string head;
|
|
||||||
|
|
||||||
assert(cached && document);
|
assert(cached && document);
|
||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
|
|
||||||
if (!init_string(&head)) return;
|
|
||||||
|
|
||||||
bool add_to_head = true;
|
|
||||||
// if (cached->head) {
|
|
||||||
// if (!strncmp(cached->head, "\r\nContent-Type: text/html; charset=utf-8\r\n",
|
|
||||||
// sizeof("\r\nContent-Type: text/html; charset=utf-8\r\n") - 1)) {
|
|
||||||
// add_to_head = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (add_to_head) {
|
|
||||||
// add_to_string(&head, "\r\nContent-Type: text/html; charset=utf-8\r\n");
|
|
||||||
// if (cached->head) add_to_string(&head, cached->head);
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlpp::Document *doc = (xmlpp::Document *)document->dom;
|
xmlpp::Document *doc = (xmlpp::Document *)document->dom;
|
||||||
xmlpp::Element* root = (xmlpp::Element *)doc->get_root_node();
|
xmlpp::Element* root = (xmlpp::Element *)doc->get_root_node();
|
||||||
|
|
||||||
@ -381,7 +364,6 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str
|
|||||||
struct string tt;
|
struct string tt;
|
||||||
|
|
||||||
if (!init_string(&tt)) {
|
if (!init_string(&tt)) {
|
||||||
done_string(&head);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::map<int, xmlpp::Element *> *mapa = (std::map<int, xmlpp::Element *> *)document->element_map;
|
std::map<int, xmlpp::Element *> *mapa = (std::map<int, xmlpp::Element *> *)document->element_map;
|
||||||
@ -397,9 +379,5 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str
|
|||||||
buffer = &tt;
|
buffer = &tt;
|
||||||
document->text = tt.source;
|
document->text = tt.source;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_to_head) {
|
|
||||||
// mem_free_set(&cached->head, head.source);
|
|
||||||
}
|
|
||||||
render_html_document(cached, document, buffer);
|
render_html_document(cached, document, buffer);
|
||||||
}
|
}
|
||||||
|
@ -889,7 +889,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, "utf-8",
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user