Skip to content

added fetch get example for non-utf8 pages#2911

Open
ProjectEli wants to merge 1 commit into
javascript-tutorial:masterfrom
ProjectEli:fetch_non-utf8
Open

added fetch get example for non-utf8 pages#2911
ProjectEli wants to merge 1 commit into
javascript-tutorial:masterfrom
ProjectEli:fetch_non-utf8

Conversation

@ProjectEli

Copy link
Copy Markdown

Still, some webpages do not follow standard UTF-8 encoding. As far as I know, fetch() does not support encoding options by default. Therefore, I added an example with error handling part (not already shown).

@CLAassistant

CLAassistant commented Mar 9, 2022

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@iliakan

iliakan commented Apr 14, 2022

Copy link
Copy Markdown
Member

Are there many pages in non-UTF in Korean (or Chinese)?

Is it a common way of using fetch, then?

@ProjectEli

ProjectEli commented Apr 14, 2022

Copy link
Copy Markdown
Author

Are there many pages in non-UTF in Korean (or Chinese)?

Yes. At least there are many Korean and Japanese websites that are not in UTF8, especially for some government websites. For Chinese, I don't have much experience. In practice, many people struggle with encodings when accessing those websites programatically.

Ideally, the owners of those websites should follow international standards. However, in most cases they don't want to change, or just give up management. From the user point of view, we want to deal with what's inside rather than the charset encoding. Therefore, this example will be meaningful for beginners to utilize without a deeper understanding on non-UTF8 encodings.

Is it a common way of using fetch, then?

I agree that this is not the intended usage of fetch. But we cannot decode those websites correctly through given methods in the document. In my opinion, it is worth including as a tutorial for practical use unless we find a better way of decoding.

@iliakan

iliakan commented Apr 14, 2022

Copy link
Copy Markdown
Member

So, for non-UTF Korean websites, when people use fetch, do they use it exactly as you say?

How did they cope before TextDecoder, I wonder? Did they use XMLHttpRequest?

@iliakan

iliakan commented May 3, 2022

Copy link
Copy Markdown
Member

up )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants