2

EDITED

hey guys.

My code is using pircBot to send IRC messages to twitch.tv.

The messages include characters such as '█▓▒ CRIT! ░░╚╡▌▌╞╗░░'

Example output code: sendMessage("#twitchraidstwitch", "/me █▓▒ CRIT! ░░╚╡▌▌╞╗░░");

So These characters originally all displayed as '?' in Eclipse. They didn't work properly until I changed my window -> preferences -> text file encoding to US-ASCII. (Though I've just learned these characters aren't even ASCII.)

When I export my project to a jar and try to run in CMD, the characters are back to '?'.

How do I got about getting this to work in cmd?

Thanks!

user1028872
  • 349
  • 4
  • 15
  • 2
    Huh? None of those characters are in ASCII. – user253751 Jan 16 '16 at 01:06
  • No? What are they UTF-8? The only 'Text file encoding' setting that got those to output correctly in eclipse was ASCII. Still how to I set the encoding to get those characters to show? – user1028872 Jan 16 '16 at 01:14
  • We'll need some reproducible code. Otherwise, we can't even be sure that your problem statement is accurate. – sstan Jan 16 '16 at 01:16
  • It's sending messages over IRC using PircBot's 'sendMessage(channel,"█▓▒ CRIT! ░░╚╡▌▌╞╗░░"); The output is correct from eclipse after I set the encoding to ASCII but '?' when running from a JAR. I'm not sure what else to give. – user1028872 Jan 16 '16 at 01:18
  • 1
    You should save all your source code as UTF-8. Also, when you encode your text for IRC, make sure you're encoding as UTF-8 too. This is just about the only sane way to get some kind of consistency with non-ASCII characters. http://utf8everywhere.org/ – Score_Under Jan 16 '16 at 01:39
  • I put the setting back to UTF-8 and it still worked from eclipse but not cmd. I'm curious why I was under the impression UTF-8 didn't work before. Am I not saving my source as UTF-8? – user1028872 Jan 16 '16 at 01:46
  • 1
    Have you also tried applying the encoding on PircBot's end with its setEncoding method? – Score_Under Jan 16 '16 at 01:50
  • character or letter in this question is not what it is . But still these kind of problem i face. – parlad Aug 08 '18 at 04:42

1 Answers1

9

Ok I got it to work.

I used setEncoding("UTF-8"); as Score_Under suggested. It didn't change anything but it didn't hurt either.

I then launched with java -Dfile.encoding="UTF-8" -jar JarFile.jar and that did the trick.

I figured it out from UTF-8 works on Eclipse but fails to work with an exported jar

Community
  • 1
  • 1
user1028872
  • 349
  • 4
  • 15