Android Base64 解码不同于 javascript 和 PhP
Android Base64 decode different from javascript and PhP
抱歉问了两次这个问题,但我研究了 2 小时...
我的 Android 中的 Base64 解码字符串有问题。
例如:
- 编码字符串:
VgFzJ1+TrFa7WsXS5w==
- javascript和PHP中的结果:
Vs'_¬V»ZÅÒç
- 我的Android中的结果:
Vs'_��V�Z���
我从这个页面找到了解决方案 Android PHP Base64 decode with different results
他们说
By this You convert the input String content to ISO-8859-1 encoded byte stream that will be decoded from base64.
这是我根据他们所说的功能解码器:
byte[] b = Base64.decode(data.getBytes("ISO-8859-1"), Base64.DEFAULT);
return new String(b, "UTF-8");// event if remove UTF8
但还是报同样的错误
不好意思,我自己解决了
从 ISO-8859-1 获取字符串非常简单
return new String(b, "ISO-8859-1")
抱歉问了两次这个问题,但我研究了 2 小时... 我的 Android 中的 Base64 解码字符串有问题。 例如:
- 编码字符串:
VgFzJ1+TrFa7WsXS5w==
- javascript和PHP中的结果:
Vs'_¬V»ZÅÒç
- 我的Android中的结果:
Vs'_��V�Z���
我从这个页面找到了解决方案 Android PHP Base64 decode with different results
他们说
By this You convert the input String content to ISO-8859-1 encoded byte stream that will be decoded from base64.
这是我根据他们所说的功能解码器:
byte[] b = Base64.decode(data.getBytes("ISO-8859-1"), Base64.DEFAULT);
return new String(b, "UTF-8");// event if remove UTF8
但还是报同样的错误
不好意思,我自己解决了
从 ISO-8859-1 获取字符串非常简单
return new String(b, "ISO-8859-1")