When using the polyfill on browsers that don't support blob but do support arrayBuffer, multibyte UTF-8 sequences don't get decoded properly.
Simple repro, you can mock the browser environment by forcefully setting support.blob false:
fetch('data:text/plain,èàì’')
.then(r => r.text())
.then(console.log) // logs "èà ì�"
Looks like this was introduced here in v3.6.15, it works alright previously. With that responseType always set, Body's text() runs the byte by byte buffer decode with String.fromCharCode(), which can't handle the multibyte sequences.
Would it make sense to only set xhr.responseType after the response headers arrive, so it can check the Content-Type as well as browser support?
When using the polyfill on browsers that don't support blob but do support arrayBuffer, multibyte UTF-8 sequences don't get decoded properly.
Simple repro, you can mock the browser environment by forcefully setting
support.blobfalse:Looks like this was introduced here in v3.6.15, it works alright previously. With that responseType always set, Body's
text()runs the byte by byte buffer decode withString.fromCharCode(), which can't handle the multibyte sequences.Would it make sense to only set
xhr.responseTypeafter the response headers arrive, so it can check the Content-Type as well as browser support?