【问题标题】:charset cp852 and ISO 8859-2字符集 cp852 和 ISO 8859-2
【发布时间】:2015-04-09 07:10:38
【问题描述】:

是否有可能从.dbf文件中加载字符集cp852

ArrayList<Map<String, Object>>();

并将其保存到编码为ISO 8859-2的xml文件会发生数据丢失吗?

在 Internet Explorer 和 java 集合中,所有字符集似乎都可以,但是当我将数据从 xml 添加到数据库时,我丢失了我的字母,例如 ąĄśŚ

【问题讨论】:

  • 您能否发布您的代码,您如何读取 XML 并将数据存储在数据库中?也许您尝试将数据存储为 UTF8。

标签: java character-encoding


【解决方案1】:

是的,这很可能显示在此代码上(尽管如果您只想导出简单的字母也可以)。

public class Sample {
    public static void main(String[] args) throws Exception {
        // try to print Upper case A with ogonek
        System.out.println(new String(new byte[] {(byte) 164}, Charset.forName("IBM852"))); // <--- will print the correct character
        System.out.println(new String(new byte[] {(byte) 164}, Charset.forName("ISO-8859-2"))); // <--- will print something else
    }
}

我这里的结果会是这样的

Ą
¤

如需进一步参考,您可以查看这两个链接

http://www.ascii-codes.com/cp852.html
http://www.calculla.com/en/iso8859_2_table?action=showAll

【讨论】:

  • 现在,如何将 cp852 更改为 ISO?
  • 嗯,你可以自己转换(cp852 -> utf-8 -> iso 8859 2 或反之)或更改数据库编码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-26
  • 1970-01-01
  • 2012-09-29
  • 2014-02-01
  • 2013-01-19
  • 1970-01-01
相关资源
最近更新 更多