Tuesday, 15 June 2010

javascript - My base64 concatenated string has = characters. How to get rid of them -


How do I add base 64 strings to get rid of "=" characters?

I sent a byte stream [] of data from the servlet as an HTTP response, and I want to open the PDF viewer in the client side. But, I can not see it due to these extra characters

I tried to merge with + =, along with being included, but I have the = character at the end of each substring. / P>

It is possible that if there is no way to insert the wire without the last character. Standard basis-64 encoding three bytes (3 * 8 bits) 4 characters (4 * 6 bit)

Encoded in If the number of bytes in the original data is not divisible by 3, then the remaining 1 is 1 and 1 is added to = , then 2 = characters are added if left 2 was.

Now, unfortunately you can not add two base-64 encoded strings if the padding character = is the first end - you have to decode both, join the binary string Do *, and then-encode, otherwise the later part will be squeezed out and all the bytes in the second part will be incorrectly decoded.

[*] This is not strictly necessary to re-code the first part, but adapted for it is also not worthwhile.


No comments:

Post a Comment