-1

I'm developing an application that is using german special chars (Using utf-8). I have set the workspace charset in eclipse to utf-8. When debbuging the app special chars all get displayed correctly, but when exporting the application (runnable jar file) and starting it then (by double-clicking in the explorer, it displays rubbish when trying to display these chars. What did I do wrong and how can I get this to work?

Thanks in advance

joz
  • 652
  • 2
  • 8
  • 19
  • It would *really* help if you'd show us the code. A short but complete program demonstrating the problem would be ideal. We have no idea whether the relevant text is embedded directly in the code or whether it's in files which are loaded at execution time, or how you're displaying the text. We don't know what "displays rubbish" means, either. – Jon Skeet Jul 22 '14 at 07:36
  • 1
    It seems that you are having trouble with your windows console not being set to UTF-8. Am I right?. [here](http://stackoverflow.com/questions/54952/java-utf-8-and-windows-console) [here](http://stackoverflow.com/questions/11927518/java-unicode-utf-8-and-windows-command-prompt) – PbxMan Jul 22 '14 at 08:02

1 Answers1

0

When you use any function related to string encoding, please explicitly use charset parameter, example: Don't do this:

String s = new String(bytes);

InputStreamReader is = new InputStreamReader(inputstream)

But use this:

String s = new String(bytes, Charset.forName("UTF-8"));

InputStreamReader is = new InputStreamReader(inputstream, "UTF-8")
yelliver
  • 5,648
  • 5
  • 34
  • 65