0

I'm trying to load a GitHub source code to my Eclipse but when I run it the output isn't as intended. What should I do to make the output appear normally?

Image

I have tried Window/Preference/General/Workspace, Window/Preference/General/Content Type and Edit/Set Encoding as well as reinstall Eclipse to try change the text encoding to UTF-8 but it still persists.

I expected the output like this: Intended result

This is the Github project I'm trying to run: https://github.com/vncorenlp/VnCoreNLP

Edit: Thank you for the various ideas and solutions given to me, but the issues hasn't been resolved so this question is still open.

  • You should probably provide a link for the github page, so we can try it on our machines as well... – Eldinur the Kolibri May 30 '23 at 07:45
  • 2
    maybe is better if you don't use "image" link and include code in post instead – Lore May 30 '23 at 07:53
  • 1
    Does the font you are using for the console actually support those characters? It looks like it doesn't. – greg-449 May 30 '23 at 07:59
  • Make sure the font used in the _Console_ view supports these characters: in preferences _General > Colors and Fonts > Appearance: Debug > Console font_ – howlger May 30 '23 at 07:59
  • @howlger Well but the default text font should support this, should'nt it? And the correct path would be Appearance > Colors and Fonts: Debug. – Eldinur the Kolibri May 30 '23 at 08:04
  • @P. Hammer Nick Have you tried this: https://stackoverflow.com/questions/4947484/how-to-set-eclipse-console-locale-language ? Changing it to vietnamese? – Eldinur the Kolibri May 30 '23 at 08:10
  • I have tried changing fonts to the one that should support the character but the same issue still appears, and its my first post so I'm not allowed to bring up images yet. – P. Hammer Nick May 30 '23 at 08:12
  • @Eldinur Thanks for correcting the path. It depends on the system and the preferences. Please note, one wrongly displayed character is one character in the code, so it isn't an UTF-8 vs. code page encoding problem. – howlger May 30 '23 at 08:16
  • @Eldinur well this will change all my script to Vietnamese and I wouldn't want it. I only want the output to render normally. – P. Hammer Nick May 30 '23 at 08:17
  • 1
    Copy the output from the _Console_ view and paste it into the Java editor (and vice versa). If the characters are shown correctly in the Java editor, but not in the _Console_, it's the _Console_ font. – howlger May 30 '23 at 08:19
  • @howlger Yes I agree. This should probably fix it. (As an aside, cool videos) – Eldinur the Kolibri May 30 '23 at 08:21
  • @howlger the characters can only show correctly in the editor when I code, and when I paste it back again from console to editor it doesn't revive the characters because the console has modified it already. – P. Hammer Nick May 30 '23 at 08:24
  • What exactly did you do change the text encoding to UTF-8? In the run configuration, which encoding is chosen in the _Common_ tab? Please include a minimal example that prints e.g. `Ô` and the output, both as text in your question. – howlger May 30 '23 at 08:42
  • @howlger Its by default, inherited from workspace, which is UTF-8. The example program prints Ô as � which is of course an ambiguous character. I doubt if its actually UTF-8's fault, but actually my friends are not having that problem and they use UTF-8, so I can't really know why. It's why I create this post despite all the efforts trying to fix it. – P. Hammer Nick May 31 '23 at 09:41
  • How is `System.out.println("Ô\u00d4");` shown in your _Console_ view? I'm getting `ÔÔ` as expected. If you get the same letter twice, then your problem is not related to your source code, but how you run the bytecode and/or the output is shown. In this case, please show the command line (in the run configuration, there is a _Show Command Line_ button for that) and tell with which Java version you run your code (be aware that Java 18 and higher behaves different than older versions because of [JEP 400](https://openjdk.org/jeps/400)). – howlger May 31 '23 at 11:40
  • @howlger It's �� in the console, which is unable to display on the white console unless I copy and paste it here resulting in ambiguous character. The command line in the configuration is too long to appear so I will have to split it into three comments. It seems yes I'm running in JDK 18.0.2. C:\Program Files\Java\jdk-18.0.2\bin\javaw.exe -Dfile.encoding=UTF-8 -classpath "C:\Users\admin\Desktop\VnCoreNLP-1.2\target\test-classes;C:\Users\admin\Desktop\VnCoreNLP-1.2\target\classes;C:\Users\admin\.m2\repository\com\optimaize\languagedetector\language-detector\0.6\language-detector-0.6.jar; – P. Hammer Nick Jun 02 '23 at 06:45
  • C:\Users\admin\.m2\repository\net\arnx\jsonic\1.2.11\jsonic-1.2.11.jar;C:\Users\admin\.m2\repository\com\intellij\annotations\12.0\annotations-12.0.jar;C:\Users\admin\.m2\repository\com\google\guava\guava\18.0\guava-18.0.jar;C:\Users\admin\.m2\repository\vncorenlp\marmot\1.0\marmot-1.0.jar;C:\Users\admin\.m2\repository\edu\emory\mathcs\nlp\nlp4j-api\1.1.3\nlp4j-api-1.1.3.jar;C:\Users\admin\.m2\repository\org\tukaani\xz\1.5\xz-1.5.jar;C:\Users\admin\.m2\repository\it\unimi\dsi\fastutil\7.0.12\fastutil-7.0.12.jar; – P. Hammer Nick Jun 02 '23 at 06:45
  • C:\Users\admin\.m2\repository\org\magicwerk\brownies-collections\0.9.13\brownies-collections-0.9.13.jar;C:\Users\admin\.m2\repository\org\apache\commons\commons-math3\3.5\commons-math3-3.5.jar;C:\Users\admin\.m2\repository\org\apache\commons\commons-csv\1.2\commons-csv-1.2.jar;C:\Users\admin\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;C:\Users\admin\.m2\repository\org\slf4j\slf4j-log4j12\1.7.5\slf4j-log4j12-1.7.5.jar;C:\Users\admin\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar" -XX:+ShowCodeDetailsInExceptionMessages Test – P. Hammer Nick Jun 02 '23 at 06:46
  • That proofs that in the font that you use in the _Console_ view, the character `Ô` is missing. Consider to use [Source Code Pro](https://github.com/adobe-fonts/source-code-pro/tree/release/TTF) or a different font containing `Ô`. – howlger Jun 02 '23 at 06:53
  • @howlger how does the font miss the character Ô in the console while it's appearable in text editor. – P. Hammer Nick Jun 02 '23 at 07:12
  • As far as I know, in the text editor, if a character is missing in a font, the character is taken from another font. I guess this is not the case in the _Console_ view. If it would be an encoding problem of the source code, then `\u00d4` would work. – howlger Jun 02 '23 at 08:03
  • @howlger That is true for fonts that doesn't support the characters. But here I use a font that support the character, so the characters appear properly with it's font style in the text editor. But when it comes to the console it doesn't appear as intended anymore. Still not resolved :/ – P. Hammer Nick Jun 06 '23 at 10:12
  • I doubt that you use a font that supports the character `Ô`. So please prove it. How does it look with the Source Code Pro font? As already proven, it cannot be a problem with the encoding of the source code as `\u00d4` didn't show up correctly with the font you use either. – howlger Jun 06 '23 at 10:57
  • @howlger Just had a quick glance at the default Source Code Pro font and looks like it supports Vietnamese characters as I googled it. So here is how it looks with Source Code Pro font: https://imgur.com/a/wh5fzNB. You can clearly see that while the text editor rendered it properly, it's not the same for the console. – P. Hammer Nick Jun 07 '23 at 07:59
  • Okay, you are right, using the Source Code Pro font does not fix it. Could you please try a more up to date Java? You use Eclipse 2023-03, right? Keep in mind, UTF-8 by default (JEP 400) has been introduced in Java 18 and Eclipse also had to be adapted for JEP 400. – howlger Jun 07 '23 at 11:23

0 Answers0