英文:
VS Code terminal not using same codepage as VS Code editor
问题
如何告诉VS Code终端使用与编辑器相同的代码页?
这段代码:
class Program {
static void Main(string[] args) {
WriteLine("你好世界");
}
}
(以UTF-8编码)在VS Code终端中使用dotnet run
运行时输出你好世界
而不是正确的字符。屏幕截图:
我尝试在终端中运行chcp 1252
,但没有任何变化。如何调整终端设置以正确显示文本,使用正确的代码页?
英文:
How do I tell VS Code terminal to use same codepage as Editor?
This code:
class Program {
static void Main(string[] args) {
WriteLine("æøå;ÆØÅ");
}
}
(encoded in UTF-8 with BOM) outputs æoå;ÆOÅ
instead of æøå;ÆØÅ
when run with dotnet run
in the VS Code terminal. (Notice the ø and Ø are rendered as o and O.)
Screen shot:
I tried chcp 1252
in the terminal but it made no difference.
How can I adjust the terminal settings to display the text correctly, with the right code page?
答案1
得分: 1
以下是您要翻译的内容:
"它就像这样。我相当确定VS Code会尝试检测编码(您也可以手动指定),但终端中发生的事情实际上并不完全属于VS Code的管辖范围(至少默认情况下不是)。"
"通过在终端/控制台中使用chcp.com 65001
命令(或chcp 65001
,.com
可能是可选的),将您的终端/控制台的代码页切换为UTF-8。"
相关阅读:
- https://stackoverflow.com/q/57131654/11107541
- https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
英文:
It's just like that. I'm pretty sure VS Code tries to detect encoding (you can also specify manually), but what happens in the terminal is not really in VS Code's jurisdiction so to speak (at least- not by default).
Switch your terminal/console's code page to UTF-8 by using the chcp.com 65001
command in it (or chcp 65001
. the .com
might be optional).
Related readings:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论