用Java解析英镑符号

时间:2018-02-13 06:32:10

标签: java xml-parsing non-ascii-characters

我从包含Pound'£'符号的外部系统获取输入文本,该符号需要在我们的系统中进行解析和存储。问题是 - 它会被转换为垃圾字符吗?在solaris / unix中运行时标记。

注意 - 应用程序在Windows中正常运行,但在solaris和unix中,它会破坏符号。我们的Solaris有jdk1.6.x

我尝试使用字符编码 - UTF-8,UTF-16和ISO8859_1,但无济于事。 请帮忙。

示例代码只包含一个包含文本的文本文件:THE£1 HOUSES

InputStream is = null;
DataInputStream in = null; 
try {
    is = new FileInputStream(new File("src//resources//mytext.txt"));
    in = new DataInputStream(is);
    BufferedReader br = new BufferedReader(new InputStreamReader(in, "ISO8859_1"));
    System.out.println("Total file size to read (in bytes) : " + is.available());
    String sCurrentLine;
    while ((sCurrentLine = br.readLine()) != null) {
        System.out.println(sCurrentLine);
    }
} catch(IOException e) {
    e.printStackTrace();
}

嗨@Jim Garrison,我在unix中使用了以下命令来生成hexdump

od -x mytext.txt

它是 -

0000000 5448 4520 a331 2048 4f55 5345 5300
0000015

0 个答案:

没有答案
相关问题