0

I have one CSV file which contains many records. Noticed that some of the records contain French characters. My script reads each record and processes it and inserts the processed record in the XML. When we view the .csv file on terminal using VIM Editor on Fedora system, the French characters are displayed in correct format. But after processing the records these characters are not getting displayed properly. Also when such a record is printed on the console, it is not displayed properly.

For eg.

String in .csv file : Crêpe Skirt

String in XML : Cr�pe Skirt

code Snippet for Reading file.

BufferedReader file = new BufferedReader(new FileReader(fileLocation));

String line = file.readLine();

Kindly suggest a way to handle such issue.

1
  • 4
    Please include your code for opening and reading the file. It is probably as simple as specifying "UTF-8" encoding then reading the file. Commented Dec 16, 2013 at 10:20

2 Answers 2

2

You need to know what encoding the file is in (probably UTF-8) and then when you open the file in Java specify the same encoding.

Sign up to request clarification or add additional context in comments.

Comments

2

try reading the file as UTF-8 file. And provide the encoding of your xml file as UTF-8 too

 BufferedReader reader=new BufferedReader(new InputStreamReader(new FileInputStream(your-file-path),"UTF-8"));

    String line="";
    while((line=reader.readLine())!=null) {
        //Do your work here
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.