【发布时间】:2013-01-04 13:52:52
【问题描述】:
我正在尝试从数据库中获取和更新简体中文字符(GB2312),更新部分在 weblogic 10.3 windows 机器中工作正常,但在 weblogic 10.3 Solaris 机器中失败(垃圾字符),但获取和显示中文字符是在两种环境中都能正常工作
获取 DAO
while (rs.next()) {
Base64 base64 = new Base64();
byte[] notesByte = base64.encode(rs
.getBytes("notes"));
}
用户界面(Android)
byte[] notes= Base64.decode(notesByteStr , Base64.DEFAULT);
notesText.setText(new String(notes, "GB2312")); // Displaying chines char
notesByte= Base64.encode(notesText.getText().toString().trim().getBytes("GB2312"), Base64.DEFAULT) // send to db
更新 DAO
getSession().createSQLQuery(notesUpdateQuery)
.setParameter(0, new String(base64.decode(notesByte)))
.executeUpdate();
注意:源txt文件编码:UTF-8
【问题讨论】:
-
我已经尽我所能回答了这个问题,但是“它失败了”没有给我们任何关于实际出了什么问题的信息。请阅读tinyurl.com/so-list
-
实际上已更新为垃圾字符,例如?????
-
你的意思是你实际上得到了问号,还是你得到了你没想到的其他字符?
标签: java utf-8 character-encoding weblogic gb2312