-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Add an example to show how to handle a non-UTF-8 page #39385
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
base: main
Are you sure you want to change the base?
Conversation
// Get the charset from the page meta tag | ||
const part = decoder.decode(combinedArray.slice(0, 1000)); | ||
const charset = part.match(/<meta charset="(.+?)">/)[1]; | ||
// Creates a new TextDecoder object with the label "shift_jis" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
// Creates a new TextDecoder object with the label "shift_jis" | |
// Creates a new TextDecoder object with the label "shift_jis" |
Preview URLs (comment last updated: 2025-05-10 12:14:21) |
This is the first I've heard of You indirectly mentioned that TextEncoder only supports encoding content in UTF-8. Rather than try to encode the modified document back into Also tagging @rebloor and @pepelsbey in case there are MDN editorial considerations that I'm not aware of here. |
Description
The example shows two things:
Motivation
All other examples are for a UTF-8 page.
Additional details
Related issues and pull requests