Last active
April 25, 2021 15:24
-
-
Save nelsonfncosta/b94d1d1a5ee3cc922f138253b48092b5 to your computer and use it in GitHub Desktop.
ArrayBuffer to String example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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