VS Code terminal not using same codepage as VS Code editor

huangapple go评论51阅读模式
英文:

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运行时输出你好世界而不是正确的字符。屏幕截图:VS Code terminal not using same codepage as VS Code editor

我尝试在终端中运行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: VS Code terminal not using same codepage as VS Code editor

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。"

相关阅读:

英文:

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:

huangapple
  • 本文由 发表于 2023年5月13日 22:19:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76243194.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定