java连接sybase数据库中文乱码问题

xiaoxiao2021-02-28  14

最近刚接触sybase数据库,发现sybase分为cp936和cp850两种字符集,我用java编程,正常连接cp936的数据库读取中文是没问题的,但是cp850的就会出现乱码。后来在网上查了一下,经过测试发现,加上如下代码就可以解决中文乱码问题了。

String str = "......";//此处是数据库的数据 String strCode = new String(str.getBytes("iso-8859-1"),"GBK"); System.out.println(strCode);
转载请注明原文地址: https://www.6miu.com/read-1650406.html

最新回复(0)