added fetch get example for non-utf8 pages
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).
Are there many pages in non-UTF in Korean (or Chinese)?
Is it a common way of using fetch, then?
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.
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?
up )