Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JAVA转换器不使用某些符号(西里尔文等)_Java_Unicode_Utf 8 - Fatal编程技术网

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

JAVA转换器不使用某些符号(西里尔文等),java,unicode,utf-8,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 in

我的程序不能处理像ą、č、ę、ė、ė等符号。我应该在这段代码上写些什么,它开始处理所有符号? 我在论坛上找不到类似的话题。有人能给我小费吗

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();
  }
 }
}
导入java.io.BufferedReader;
导入java.io.IOException;
导入java.io.InputStreamReader;
公共类Unicode{
公共静态void main(字符串[]args){
InputStreamReader InputStreamReader=新的InputStreamReader(System.in);
BufferedReader BufferedReader=新的BufferedReader(inputStreamReader);
试一试{
字符串行=null;
而((line=bufferedReader.readLine()).length()>0){
对于(int index=0;index
它给了我这个: Unicode:U+FFFD
EF BF BD

可能的副本实际上这个地方没有按我想要的那样工作:
String b=line;字节[]y=b.getBytes(“UTF-8”);对于(字节x:y){System.out.print(Integer.toHexString(x&0xFF).toUpperCase());}
这个地方的可能副本实际上没有按我想要的那样工作:
字符串b=line;字节[]y=b.getBytes(“UTF-8”);对于(字节x:y){System.out.print(Integer.toHexString(x&0xFF.toUpperCase());}