0

Below, a piece of code to create a table in console:


System.out.format( "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓%n" );
System.out.format( "┃                    Party                 ┃%n" );
System.out.format( "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛%n" );
String align = "┃ %-30s ┃%n";

When i execute it from IDE, the output is like:

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                    Party                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

But after i package classes with mvn package, those lines show as ? in output:

????????????????????????????????????????????
?                    Party                 ?
????????????????????????????????????????????

Any way to prevent this to show table with question marks? I know using + or - would solve but i want it to show like that.

miador
  • 358
  • 1
  • 5
  • 20
  • I think it's not a maven problem. which ide do you use? Have you tried applying encoding as UTF-8 in IDE? – Insung Park Nov 24 '20 at 14:43
  • Please post your maven pom file and build execution, or have a look [here](https://stackoverflow.com/q/3017695/6015339) and ensure you have `UTF-8` encoding correctly setup. – Glains Nov 24 '20 at 14:54

1 Answers1

0

This is an encoding problem. Either that the Java compiler does not read the source using the character set you expect, or that the terminal in which you run your code does not support rendering the characters you are outputting.

The easiest is most likely to create a String with the troublesome characters, and then loop over the string and print out the Unicode value of each character. If it is 63 - question mark - then look at the encoding of your sources. If it is what you expected it to be, then look at the code page/encoding of your terminal.

If you can run your program under a debugger, you do not have to alter your program but can just set a breakpoint at System.out.format and then inspect the string passed in.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347