简体   繁体   English

System.out.println("हि") 显示“??” 在 Visual Studio Code 终端中 - 如何停止?

[英]System.out.println("हि") displays "??" in Visual Studio Code Terminal - How to Stop This?

Whenever I try to print out any Hindi characters in the Visual Studio Code Terminal via System.out.println(वा);, it directly prints out a??每当我尝试通过 System.out.println(वा); 在 Visual Studio Code 终端中打印出任何印地语字符时,它会直接打印出一个?? instead of the proper character.而不是正确的字符。 BTW I am using Windows 10.顺便说一句,我正在使用 Windows 10。

Note that this problem isn't only exclusive to Hindi characters.请注意,此问题不仅限于印地语字符。 If I try to print "₉" it also gives me a?.如果我尝试打印“₉”,它也会给我一个?。

I have tried many things:我尝试了很多事情:

  1. Checked my font - it is Consolas, 'Courier New', monospace, which should support UTF-8?检查我的字体 - 它是 Consolas,'Courier New',等宽字体,应该支持 UTF-8?

  2. When I do chcp it displays: Active code page: 65001当我执行 chcp 时,它显示:活动代码页:65001

  3. I added json code in the settings that automatically makes the Active我在自动激活的设置中添加了 json 代码

  4. Code Page equal to 65001 whenever I open a terminal每当我打开终端时,代码页等于 65001

  5. Set windows Locale to support UTF-8.设置 windows Locale 支持 UTF-8。

  6. Uninstalled and Installed Visual Studio Code.卸载并安装 Visual Studio Code。

  7. When I ran the code in PYTHON, it correctly displayed the hindi characters.当我运行 PYTHON 中的代码时,它正确显示了印地文字符。

  8. When I ran the code in a different IDE called Eclipse IDE, it displayed the hindi characters.当我在名为 Eclipse IDE 的另一个 IDE 中运行代码时,它显示了印地文字符。

  9. I am my whits end and I have seemed to try everything.我是我的白痴,我似乎已经尝试了一切。 Any help very much appreciated - I have been on this simple issue for 5+ hours.非常感谢任何帮助 - 我已经在这个简单的问题上解决了 5 个多小时。

Code When Running运行时的代码

Font Settings字体设置

Settings.json.user code to make UTF-8 encoding automatic (got from online) Settings.json.user code 使 UTF-8 编码自动(从网上获得)

Settings.json.workplace code to make UTF-8 encoding automatic (also got from online, but different place settings.json.workplace 代码使UTF-8编码自动(也是从网上得到的,但不同的地方

Using UTF-8 for Windows Locale将 UTF-8 用于 Windows 语言环境

  1. Exit VS Code退出 VS 代码

  2. Use Windows File Manager, show hidden files使用 Windows 文件管理器,显示hidden文件

  3. Open C:\Users\YourUserName\AppData\Roaming\Code\User\settings.json打开C:\Users\YourUserName\AppData\Roaming\Code\User\settings.json

Add this:添加这个:

{
    "terminal.integrated.profiles.windows": {
        
        "Command Prompt": {
            "path": "C:\\Windows\\System32\\cmd.exe",
            "args": ["-NoExit", "/K", "chcp 65001"]
                }
    },
    "terminal.integrated.defaultProfile.windows": "Command Prompt"
}
  1. Save it保存

  2. Start VS Code, open your java, click Run .启动VS Code,打开你的java,点击Run

A simple and effective way: use the Code Runner extension.一种简单有效的方法:使用Code Runner扩展。

Use Run Code to run the code after installing the extension.使用Run Code代码在安装扩展后运行代码。 The result will be displayed in the OUTPUT panel结果会显示在OUTPUT面板

在此处输入图像描述

You need to make sure that your current version of Java is up to date.您需要确保 Java 的当前版本是最新的。 If it is version 8, then it will not be able to process special characters, nor print them out.如果是版本 8,则无法处理特殊字符,也无法打印出来。 Thus, install the newest version of java (anything higher than 17 should work) and your characters will be able to be displayed properly.因此,安装最新版本的 java(任何高于 17 的版本都可以),您的角色将能够正常显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM