Difference between InputStreamReader in java 1.6 and java 1.7

61 views Asked by At

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
0

There are 0 answers