You should specify the character set in the call to getBytes()
when you are converting the string to its GB2312 encoding:
String baseString=new String(base64.encode(gb2312.getBytes("GB2312")));
In principle (and to be completely safe) you should do it when you are converting from Base64 (str.getBytes()
), but the default character encoding is probably okay since base-64 encoding uses a subset of US-ASCII. Who knows—you might be running on a platform where the default encoding is EBCDIC.