browser: force UTF-8 by default for page encoding

This commit is contained in:
Pierre Tachoire
2024-01-12 16:12:14 +01:00
parent a7fe94db88
commit 3f23f2e7ef
2 changed files with 3 additions and 2 deletions

View File

@@ -209,7 +209,8 @@ pub const Page = struct {
// https://html.spec.whatwg.org/#read-html
fn loadHTMLDoc(self: *Page, reader: anytype) !void {
log.debug("parse html", .{});
const html_doc = try parser.documentHTMLParse(reader);
// TODO pass an encoding detected from HTTP headers.
const html_doc = try parser.documentHTMLParse(reader, "UTF-8");
const doc = parser.documentHTMLToDocument(html_doc);
// save a document's pointer in the page.

View File

@@ -86,7 +86,7 @@ pub fn HTMLFileTestFn(out: File) !void {
const file = try std.fs.cwd().openFile("test.html", .{});
defer file.close();
const doc_html = try parser.documentHTMLParse(file.reader());
const doc_html = try parser.documentHTMLParse(file.reader(), "UTF-8");
// ignore close error
defer parser.documentHTMLClose(doc_html) catch {};