Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import Chinese articles #459

Open
slipbox opened this issue Nov 7, 2023 · 1 comment
Open

Cannot import Chinese articles #459

slipbox opened this issue Nov 7, 2023 · 1 comment

Comments

@slipbox
Copy link

slipbox commented Nov 7, 2023

Cannot import Chinese articles, it displays as garbled characters.
For example: http://www.nopss.gov.cn/n1/2023/0802/c431029-40049194.html

image

lable:bug

@mdroidian
Copy link
Collaborator

Initial exploration:

const enc = charset(r.headers) || "utf-8";
const buffer = iconv.encode(r.encoded, "base64");
const html = iconv.decode(buffer, enc);
const headIndex = html.indexOf("<head>") + "<head>".length;
const base = document.createElement("base");
base.href = url;
base.target = "_blank";
const htmlWithBase = `${html.substring(0, headIndex)}${
base.outerHTML
}${html.substring(headIndex)}`;
const doc = new DOMParser().parseFromString(htmlWithBase, "text/html");
const parsedDoc = new Readability(doc).parse();

  • not frontend / roam issue: copy/paste works and html (ln 109) shows untranslatable characters
  • charset(r.headers) is returning utf8
  • iconv-lite says "Untranslatable characters are set to � or ?. No transliteration is currently supported."

Options for next steps

  • check what is happening in apiPost, r.encoded
  • find different character encodings provider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants