To prevent 'InvalidCharacterError' error, you need to do this:

var base64EncodedStr = btoa(unescape(encodeURIComponent(rawData)));
Answer from Frane Poljak on Stack Overflow
๐ŸŒ
Code Beautify
codebeautify.org โ€บ binary-to-base64-converter
Binary to base64 Converter
Binary to Base64 Converter Online helps to convert plain Binary to Base64 and helps to save and share Binary with Base64.
๐ŸŒ
Cryptii
cryptii.com โ€บ pipes โ€บ binary-to-base64
Binary to base64: Convert between bytes and base64 - cryptii
Base64 encoding schemes are used when binary data needs to be stored or transferred as textual data. Therefore 64 characters are chosen that are both members of a subset common to most encodings (ASCII), and also printable.
๐ŸŒ
Base64 Encode
base64encode.org
Base64 Encode and Decode - Online
Packs of 6 bits (6 bits have a maximum of 64 different binary values) are converted into 4 numbers (24 = 4 * 6 bits) which are then converted to their corresponding values in Base64.
๐ŸŒ
Base64 Decode
base64decode.org
Base64 Decode and Encode - Online
Packs of 6 bits (6 bits have a maximum of 64 different binary values) are converted into 4 numbers (24 = 4 * 6 bits) which are then converted to their corresponding values in Base64.
๐ŸŒ
Terrific
terrific.tools โ€บ data โ€บ binary-to-base64
Binary to Base64 Converter [2026] | terrific.tools
Supports both standard Base64 and URL-safe Base64 encoding. Option to group input binary digits (bits) for improved readability (e.g., by 4 bits or 8 bits).
๐ŸŒ
Online Tools
emn178.github.io โ€บ online-tools โ€บ base64_encode.html
Base64 Encode - Online Tools
Encode text or binary to Base64 online using UTF-8, UTF-16, Hex, custom alphabets, Base64URL, MIME, UTF-7, and IMAP variants.
Find elsewhere
๐ŸŒ
Teleport
goteleport.com โ€บ home โ€บ resources โ€บ tools โ€บ hex to base64 converter | instant hex to base64 conversion
Hex to Base64 Converter | Instant Hex to Base64 Conversion | Teleport
Instantly transform your hexadecimal strings into Base64 encoding using this free online tool. Loading tool configuration... ... Have you ever needed to send binary data, like an image or a file, through systems designed for text?
๐ŸŒ
Base64Encode.org
base64encode.org โ€บ enc โ€บ bin
Base64 Encoding of "bin" - Online
Packs of 6 bits (6 bits have a maximum of 64 different binary values) are converted into 4 numbers (24 = 4 * 6 bits) which are then converted to their corresponding values in Base64.
๐ŸŒ
Make Community
community.make.com โ€บ questions
How to convert from binary to base64? - Questions - Make Community
December 5, 2023 - Hi, Iโ€™m trying to attach a PDF in a email in Postmark and they ask me to send it as Base64. Iโ€™m downloading the file using an http request and it returns me binary data, how can I convert it to Base64? Thanks
๐ŸŒ
Make Community
community.make.com โ€บ questions
Convert binary to base64 string to image - Questions - Make Community
April 2, 2023 - Here is my workflow - The 1st step http API call returns a binary code - The 2nd step I convert it to a base64 (This is returning a correct result as I have checked the image in a base64 image display) - The 3rd step I am trying to download the image to Drive - The 3rd step is failing, I am ...
๐ŸŒ
Motobit Software
motobit.com โ€บ util โ€บ base64-decoder-encoder.asp
Base64 Online - base64 decode and encode
This online sample demonstrates functionality of a base64 property, ByteArray class and Huge asp file upload. You can convert texts using several code pages (using CharSet property) from Unicode string to byte array and then convert the binary data to a Base64 string.
๐ŸŒ
Fumdum
fumdum.com โ€บ convert โ€บ base64
Convert Base64
Binary represents numbers using a series of 0's and 1's. Encode or decode URI to text, hexadecimal, base64, and more.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Glossary โ€บ Base64
Base64 - Glossary - MDN Web Docs - Mozilla
Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by transforming it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding.
๐ŸŒ
Cryptii
cryptii.com โ€บ pipes โ€บ base64-to-binary
Base64 to binary: Encode and decode bytes online - cryptii
Base64 encoding schemes are used when binary data needs to be stored or transferred as textual data. Therefore 64 characters are chosen that are both members of a subset common to most encodings (ASCII), and also printable.
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Base64
Base64 - Wikipedia
July 30, 2026 - Base64 is widely used for sending ... โ€“ was designed to transport 7-bit ASCII characters only. Encoding an attachment as Base64 before sending, and then decoding when received, assures older SMTP servers correctly transmit messages with attached binary informatio...
Top answer
1 of 6
2

I have solved this issue by implementing a .net component for converting to base64 string. The hard part is the binary data sent to the .net COM from ASP is received as a string. Convert.ToBase64() accepts only byte[]. So I tried converting string to byte[].

But the encoding available in .net (Unicode, ASCII, UTF) doesn't works fine. There are data loss, while these encodings are used. Finally I get it done by using StringReader object. Read char by char(16 bit) and converted them to (8 bit) byte[] array.

And the performance is best.

Regards, Siva.

2 of 6
1

you should use the .NET methods Convert.ToBase64String and Convert.FromBase64String.

Use the Convert.FromBase64String( ) method. This will give you the binary data back (as a byte array).

To convert binary data to a Base64 string see conversion functions from binary data to a string in vbscript

from http://www.motobit.com/tips/detpg_Base64Encode/

Function Base64EncodeBinary(inData)
  Base64EncodeBinary = Base64Encode(BinaryToString(inData))
End Function

Function Base64Encode(inData)
  'rfc1521
  '2001 Antonin Foller, Motobit Software, http://Motobit.cz
  Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
  Dim cOut, sOut, I

  'For each group of 3 bytes
  For I = 1 To Len(inData) Step 3
    Dim nGroup, pOut, sGroup

    'Create one long from this 3 bytes.
    nGroup = &H10000 * Asc(Mid(inData, I, 1)) + _
      &H100 * MyASC(Mid(inData, I + 1, 1)) + MyASC(Mid(inData, I + 2, 1))

    'Oct splits the long To 8 groups with 3 bits
    nGroup = Oct(nGroup)

    'Add leading zeros
    nGroup = String(8 - Len(nGroup), "0") & nGroup

    'Convert To base64
    pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _
      Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _
      Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _
      Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)

    'Add the part To OutPut string
    sOut = sOut + pOut

    'Add a new line For Each 76 chars In dest (76*3/4 = 57)
    'If (I + 2) Mod 57 = 0 Then sOut = sOut + vbCrLf
  Next
  Select Case Len(inData) Mod 3
    Case 1: '8 bit final
      sOut = Left(sOut, Len(sOut) - 2) + "=="
    Case 2: '16 bit final
      sOut = Left(sOut, Len(sOut) - 1) + "="
  End Select
  Base64Encode = sOut
End Function

Function MyASC(OneChar)
  If OneChar = "" Then MyASC = 0 Else MyASC = Asc(OneChar)
End Function