JAVA转换器不使用某些符号(西里尔文等)

时间:2017-01-30 21:04:10

标签: java unicode utf-8

我的程序不适用于这些符号,如ą,č,ę,ė,€等等。我应该在这段代码上写下它开始使用所有符号? 我无法在论坛中找到类似的主题。有人可以给我一个提示吗?

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Unicode {

public static void main(String[] args) {

InputStreamReader inputStreamReader = new InputStreamReader(System.in);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

try {

  String line = null;
  while ((line = bufferedReader.readLine()).length() > 0) {
    for (int index = 0; index < line.length(); index++) {

      String hexCode = Integer.toHexString(line.codePointAt(index)).toUpperCase();

      String hexCodeWithAllLeadingZeros = "0000" + hexCode;
      String hexCodeWithLeadingZeros = hexCodeWithAllLeadingZeros.substring(hexCodeWithAllLeadingZeros.length()-4);
      String a = "U+" + hexCodeWithLeadingZeros;

      System.out.println("Unicode: "+a);

      String b = line;
        byte[] xxx = b.getBytes("UTF-8");

        for (byte x : xxx) {
        System.out.print(Integer.toHexString(x & 0xFF).toUpperCase()+" ");
        }

      System.out.println();
      System.out.println();
    }

  }
} catch (IOException ioException) {
       ioException.printStackTrace();
  }
 }
}

它给了我这个: Unicode:U + FFFD EF BF BD

0 个答案:

没有答案