1

I have a issue with encoding conversion in java 1.7 but not in java 1.6.

The code is like this:

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String inStr = "﨑㈱";//MS932 characters but not in Shift_JIS
        InputStream bais = new ByteArrayInputStream(inStr.getBytes("MS932")); 
        BufferedReader bufferedReaderNew = new BufferedReader(new InputStreamReader(bais, "SJIS"));//MS932 to SJIS
        System.out.println(bufferedReaderNew.readLine());
    }
}

In Java1.6, the output is

��

But in Java1.7, the output is

�ア��

So I am looking some reasonable explanation regarding

  1. What is the difference between InputStreamReader in Java 1.6 and Java 1.7
  2. What should I fix to get the same result as Java 1.6
c.miloss
  • 11
  • 1
  • Both of these Java versions are pretty old. Is this still relevant? – Henry Sep 28 '20 at 17:18
  • Finally, We upgraded to Java 1.8. The result of java1.8 is the same as 1.7, so I thought there might be a difference between 1.6 and 1.7. – c.miloss Sep 29 '20 at 01:15

0 Answers0