Android Php Base64 Decode With Different Results
I have a big problem : I don't have the same result if I do base64_decode($string); in php or if I do Base64.decode(string); in android. Example : with this string : WWhiZWWSZpNlaG
Solution 1:
I think this will help you, Don't use .toString()
use this instead
var str = "WWhiZWWSZpNlaGSTnpljZQ=="var decoded = String(Base64.decode(str, Base64.NO_WRAP))
I know this to late to answer :-D
Solution 2:
You should try this:
Base64.decode(content.getBytes("ISO-8859-1"), Base64.DEFAULT);
By this You convert the input String content
to ISO-8859-1
encoded byte stream that will be decoded from base64.
Solution 3:
I think the decode is fine, but Android isn't applying the right encoding (probably utf-8).
Does this content appear on an HTML page? If so, are you properly enforcing the ISO-8859-1
encoding?
Alternatively, you could also switch to UTF-8.
Post a Comment for "Android Php Base64 Decode With Different Results"