0

I am looking to take the contents of a file as a string (any file type), and convert that string into a string of Base64 solely using JavaScript for the purpose of outputting in a blob url. In many cases btoa() does not work, obviously due to it not accepting information that is not 8 bit. I need to be able to convert any string into a Base64 string. If this is possible, can someone please provide a solution?

Alek
  • 3
  • 3
  • 1
    possible duplicate of [How can you encode a string to Base64 in JavaScript?](http://stackoverflow.com/questions/246801/how-can-you-encode-a-string-to-base64-in-javascript) – Jonatan Cloutier Aug 27 '14 at 03:24
  • I saw that other question thread; however, it seems as though the proposed solutions in that thread can't handle certain characters. For instance, my script reads a PDF file as a string and these functions can't encode the string as Base64. – Alek Aug 27 '14 at 12:53
  • Right I can't write a proper answer now but look at this link https://developer.mozilla.org/fr/docs/Web/JavaScript/Base64_encoding_and_decoding – Jonatan Cloutier Aug 27 '14 at 15:39

0 Answers0