Skip to content
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

readBlobAsText does not repect the reponse charset #1059

Closed
joe06102 opened this issue Oct 15, 2021 · 2 comments · Fixed by #1361
Closed

readBlobAsText does not repect the reponse charset #1059

joe06102 opened this issue Oct 15, 2021 · 2 comments · Fixed by #1361

Comments

@joe06102
Copy link

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'
  }
@joe06102
Copy link
Author

is this repo dead?

@JakeChampion
Copy link
Owner

Hi, no, it is still maintained

JakeChampion added a commit that referenced this issue Jul 18, 2023
JakeChampion added a commit that referenced this issue Jul 18, 2023
JakeChampion added a commit that referenced this issue Jul 18, 2023
JakeChampion added a commit that referenced this issue Jul 18, 2023
JakeChampion added a commit that referenced this issue Jul 18, 2023
cr313 added a commit to cr313/fetch-Js-flow that referenced this issue Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@JakeChampion @joe06102 and others