Reputation: 207
I am using OpenCSV 2.3 to read and write files data, but when, I switch Windows PC into in Japanese Language then, I notice that OpenCSV write file method internally uses Print writer that is converting yen char to \ As a result - the CSV file created ends up with unescaped \, and reading such file using CSVReader fails.
How could I fix this problem ?
Upvotes: 1
Views: 749
Reputation: 207
Further investigated more on this problem and noticed that, this is not a problem of CSVWrite file method. Although, CSVWrite file methods is working Fine.
Now, Where is problem?
Previously, I was using FileWriter, It uses the system default Encoding. (In other words, If we uses the FileWriter then encoding of writing/reading files is depends on the mercy of Writer).
So, I tried/use
csvReader = new CSVReader(new BufferedReader(new InputStreamReader(new FileInputStream(inputFile), "UTF-8")));
to tell the Reader and Writer just read and write file in specified Encoding system not on systems's default.
Upvotes: 1