发送:
$datas = $this->fhuiben_db->fetch_array();
$datas[0]['summary']=base64_encode($this->toUtf8($datas[0]['summary']));
$datas[0]['content']=base64_encode($this->toUtf8($datas[0]['content']) );
// $datas['summary']= json_encode($datas['summary'],JSON_UNESCAPED_UNICODE);
// $datas['content']=json_encode($datas['content'], JSON_UNESCAPED_UNICODE);
// echo $datas[0]['content'];
echo JSON($datas);
publicfunction toUtf8($str){
$encode= mb_detect_encoding($str, array("ASCII","GB2312","UTF-8","GBK","BIG5"));
$str= iconv($encode,"UTF-8",$str);
return($str);
}
System.out.println(getFromBASE64(returnResult.get(0).summary));
System.out.println(getFromBASE64(returnResult.get(0).content));
// 将 BASE64 编码的字符串 s 进行解码
public static String getFromBASE64(Strings) {
if (s == null) return null;
BASE64Decoder decoder = newBASE64Decoder();
try {
byte[] b = decoder.decodeBuffer(s);
return new String(b,"UTF-8");
} catch (Exception e) {
return null;
}
}
// 将 s 进行 BASE64 编码
public static String getBASE64(String s) {
if (s == null) return null;
return (new BASE64Encoder()).encode( s.getBytes() );
}
原来是这个包:import sun.misc.BASE64Decoder;
import Decoder.BASE64Decoder;
import Decoder.BASE64Encoder;