Skip to content

Instantly share code, notes, and snippets.

@nelsonfncosta
Last active April 25, 2021 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsonfncosta/b94d1d1a5ee3cc922f138253b48092b5 to your computer and use it in GitHub Desktop.
Save nelsonfncosta/b94d1d1a5ee3cc922f138253b48092b5 to your computer and use it in GitHub Desktop.
ArrayBuffer to String example
function arrayBufferToString (buffer, encoding = 'UTF-8', callback = console.log) {
const blob = new Blob([buffer], { type: 'text/plain' })
const reader = new FileReader()
reader.onload = evt => callback(evt.target.result)
reader.readAsText(blob, encoding)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment