Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Read Japanese Kanji chars from CSV file encoded in Shift-JIS

kumadeJun 29 2015 — edited Jun 30 2015

Greetings to everyone.

I have an issue with reading Japanese Kanji characters from CSV-file encoded in Shift-JIS, which can be uploaded through usual html-form submit or flex application.

I'm using the following code for this:


//content is an array of bytes, returned after user submits the file
ByteArrayInputStream in = new ByteArrayInputStream(content);
BufferedReader br = new BufferedReader(new InputStreamReader(in, Const.ENCODING_SHIFT_JIS));
String strLine;
try {
  
while (true) {
  strLine
= br.readLine();
  
//processing CSV line by line and eventually writing data to DB
...

When I'm debugging the strLine variable - I see only question marks instead of Kanji Japanese characters (in particular, I've tested it on Kanji character 裵). Other Japanese characters seems to be ok (for example 〒 character). In debug window (and later in my DB) it appears like this: 〒���

If I'm doing the same things, but have file encoding UTF-8 and Const.UTF-8 instead of Const.ENCODING_SHIFT_JIS in my code - everything works fine. But client needs Shift-JIS file encoding support.

Can anyone tell me what's the problem here?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 28 2015
Added on Jun 29 2015
4 comments
15,069 views