In my application, I am reading the data (Japanese text) from DB (UTF-8) and trying to write the output in SHIFT_JIS file format. However, full width ー (817C hex code in shift JIS) is getting converted as ? in the output file.
Here is the sample program to test it
public class ShiftJisTest {
public static void main(String[] args) {
String text = "東1-1";
try (BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream("output_data"), "SHIFT_JIS"))) {
writer.write(text);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Output:
東1?1
Hex Code value of output:
93 8C 82 50 3F 82 50
Garbled character in HEX: 3F
, expected was 81 7C