-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
I'm working on a react-native project which is dependent of this lib. But I found the readBlobAsText does not respect the charset in Content-Type, which throws error when the charset is not utf8-encoded.
the problematic code below:
function readBlobAsText(blob) {
var reader = new FileReader()
var promise = fileReaderReady(reader)
reader.readAsText(blob) // <-- FilerReader accept a second param 'encode', which can be retrieved from the response header.
return promise
}And here is my code suggestion:
function getEncode() {
const contentType = xhr.getResponseHeader('content-type')
return /charset=([A-Za-z0-9_\-]+)/.exec(contentType)?.[1] || 'utf-8'
}Metadata
Metadata
Assignees
Labels
No labels