I have a text file (.txt) containing words with foreign characters. For example, the first word is école
I read each line in using String lineData = inputBuffFile.readLine();
So, lineData
becomes "école
"
1) I can print the word to a Command Prompt window (as part of a user-input question) using String replOption = console.readLine(lineData)
- the é displays properly.
2) I can replace foreign characters using replaceAll
. That is, tmpWord = lineData.replaceAll("éco","!")
results in tmpWord
becoming "!le
"
Based on these two tests, the foreign character is read and stored properly.
However, if I print the word to a Command Prompt window using System.out.println(lineData)
, the é becomes another character (a capital U with the same accent mark).
I have looked through the questions on stackoverflow.com to try to understand this and have seen the suggestions to print using unicode values (which would mean I would have to convert the characters to their unicode equivalents).
Is their another way to print these out or a switch I need to include? If this has already been asked, I would appreciate a pointer.
Thank you in advance, Mike