Android的PHP的Base64德code有不同的结果 [英] Android PHP Base64 decode with different results

查看:393
本文介绍了Android的PHP的Base64德code有不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的问题:我没有相同的结果,如果我做base64_de code($字符串);在PHP或者如果我这样做Base64.de code(字符串);在android系统。

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.

例如:
以该字符串:WWhiZWWSZpNlaGSTnpljZQ ==

Example : with this string : WWhiZWWSZpNlaGSTnpljZQ==

在PHP中,结果是Yhbee'fEHDZ™CE。

In php, result is Yhbee’f"ehd"ž™ce .

在Android上,其结果是Yhbeefehdce

In android, the result is Yhbee�f�ehd���ce

我觉得这是一个编码的问题,但我不知道在哪里,我的PHP服务器的输出为ISO-8859-1,我没有找到如何告诉Base64.de code使用这种类型的编码。

I think there is an encoding problem, but I don't know where, the output of my PHP server is ISO-8859-1, I don't find how to tell to Base64.decode to use this type of encoding.

您可以帮我请。 THX答案。

Can you help me please. Thx for answers.

PS:我不能碰的PHP脚本

PS : I can't touch the PHP script.

推荐答案

您应该试试这个:

 Base64.decode(content.getBytes("ISO-8859-1"), Base64.DEFAULT);

通过这种转换,您输入的字符串内容 ISO-8859-1 连接codeD字节流这将是从德的base64 codeD。

By this You convert the input String content to ISO-8859-1 encoded byte stream that will be decoded from base64.

这篇关于Android的PHP的Base64德code有不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆