How to display unicode

Discussion in 'Spigot Plugin Development' started by TheBlueKing, May 6, 2017.

  1. How can i print a message contain unicode and color code in console?
  2. You can try using the unicode symbol itself such as », or it's code \u00BB
    (I've used one of them before, can't remember which...)
    • Optimistic Optimistic x 1
  3. I tried,doesn't work,it say ? in cmd
  4. Then use a terminal which has unicode support. Windows Command Prompt doesn't, thus they made PowerShell.
  5. Of course windows terminal supports unicode. By default it uses the characterpage 1252. It can be changed by the "chcp" command (windows prompt), e.g. execute chcp 65001 -> to switch over to UTF-8.

    However if you're using some sort of remote console (e.g. Telnet, Putty or whatever), you need to consider their supported characterset, too.
  6. not cmd problem,it display ? in minecraft chat too
  7. I guess, i did not understand your problem yet.
    What exactly is your problem?
    Unicodes from
    • config into chat
    • client message into chat
    • chat into server console
    • chat into remote console
    • remote console into server console
    • remote console into server chat
    • .....
    Which one of these points do you want to accomplish?

    What exactly have you tried?
  8. did you encode with UTF-8?
  9. Unicodes from java code into server console
    i tried
  10. Yes,it display the right message in minecraft client,but not the console
  11. Remote console or root console?

    Do you use a dedicated root server and have remote access to the root desktop? If so check the console at the root server, not via remote console.
  12. my own windows computer
  13. Bukkit uses UTF-8, windows uses (as mentioned above) characterpage 1252.
    You need to change the character page before starting the server.
    Execute "chcp 65001" before you start the server in the same terminal.
  14. it still not working
  15. What is not working???
    You still doesn't show us what you did.
    At least show us your server start command and the complete server log when your unicode symbol fails.
  16. The unicode show as [​IMG]
    Code (Text):

    [02:45:44] [Server thread/INFO]: [0;37;1m?[0;31;1mRMW[0;32;1m?????[0;37;1m?  ?[0;33;1m???? [0;37;1m? [m
    [02:45:44] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [02:45:44] [Server thread/INFO]: CONSOLE: [0;32;1mReload complete.[m
    [02:45:44] [Craft Scheduler Thread - 3/INFO]: [Vault] Checking for Updates ...
    [02:45:45] [Craft Scheduler Thread - 3/INFO]: [Vault] No new version available

    start command: java -Xmx512M -jar spigot-1.11.2.jar
    i do chcp 65001 before start the server
  17. Colors in console Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "asd");
  18. Turns out, the problem is more trivial.
    The terminal font does not support unicode characters. It's just that simple.

    By default there are 3 fonts:
    "Consolas" and "Lucida Console" only support a few special unicode characters.

    You need to add a new font (e.g. "Arial Unicode MS Standard"), which supports unicode characters, which isn't quite easy. Some registry modifications might be necessary.
    #18 Michel_0, May 6, 2017
    Last edited: May 6, 2017
  19. New fonts can be added by the windows registry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont". Once you created a new key with the value of the font there, you can select it as font in the properties window, i posted above. Not all fonts were working and only few fonts really support many unicodes. I found "DejaVu Sans mono" pretty suitable.

    But then it still doesn't work. Because Java uses the system default character set, by starting a new JRE. So you need to set the JRE encoding, too.

    In the end, this is how it works:
    1. If your plugin contains special characters inside of the code, make sure you use UTF-8 when exporting your plugin JAR. This mostly can be set by the project settings of your IDE.
      E.g. Eclipse: Project properties -> Resource -> Text file encoding.
    2. Execute "chcp 65001" before you start your server in the same terminal.
    3. Add "-Dfile.encoding="UTF-8"" as JRE startup parameter to set the Java Encoding
      E.g. complete server start command: "%JAVA_HOME%"\Java.exe -Dfile.encoding="UTF-8" -jar -Xmx2G -Xms512M spigot-1.11.2.jar
    4. Sucess.
    Code (Java):
    this.getLogger().info("Want some unicodes??? Here you go:");