英文:
Why do emojis print as weird symbols in my Java project on Visual Studio Code?
问题
Displaying UTF-8 Emojis in Java
我尝试在Visual Studio Code的Java中打印表情符号,例如 "🚢",但它会将每个表情符号替换为 "?"。
我尝试在网上找到解决方案,并发现通过导入以下内容:
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
我可以使用新的 PrintStream 进行打印,这使我写出了以下代码:
PrintStream ps = new PrintStream(new FileOutputStream(FileDescriptor.out), true, StandardCharsets.UTF_8);
ps.println("🚢");
然而,这只返回了意外的符号 "≡ƒÜó"。
我该如何使它显示预期的表情符号?
英文:
Displaying UTF-8 Emojis in java
I'm trying to print emojis such as "🚢" in java on Visual Studio Code, but it would replace every emoji with a "?"
I tried to find solutions online and found that by importing:
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
I could print using a new printStream, which got me to:
PrintStream ps = new PrintStream(new FileOutputStream(FileDescriptor.out), true, StandardCharsets.UTF_8);
ps.println("🚢");
However, this only returned unintended symbols "🚢".
How can I get it to display the intended emojis?
答案1
得分: 1
在我在VS Code和IntelliJ IDEA中都可以正常工作。
请检查您的终端和文件编码设置。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论