related codes
/ / pako.js decompression code
function unzip(b64Data){
var strData = atob(b64Data);
var charData = strData.split("").map(function(x){return x.charCodeAt(0);});
var binData = new Uint8Array(charData);
var data = pako.inflate(binData);
strData = String.fromCharCode.apply(null, new Uint16Array(data));
return strData;
}
/ / java server uses gzip for compression
public static String gzip(String primStr) {
if (primStr == null || primStr.length() == 0) {
return primStr;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip = null;
try {
gzip = new GZIPOutputStream(out);
gzip.write(primStr.getBytes());
} catch (IOException e) {
e.printStackTrace();
} finally {
if (gzip != null) {
try {
gzip.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return new sun.misc.BASE64Encoder().encode(out.toByteArray());
}
what result do you expect? What is the error message actually seen?
problem description
Chinese garbled after parsing into json string
the environmental background of the problems and what methods you have tried
the use of gzip is mainly to speed up the page request json data speed, in the server side of the Chinese encoding, js decoding is not good, ask for advice!