简体   繁体   English

Visual Studio Code 集成终端中的错误变音字母与 PowerShell 在运行和运行选择之间

[英]Wrong diacritic letters in Integrated Terminal of Visual Studio Code with PowerShell between Run and Run Selection

I have the Windows 10 with Windows-1250 encoding but in Visual Studio Code with integrated terminal I have problems with diacritic signs:我有带有 Windows-1250 编码的 Windows 10,但在带有集成终端的 Visual Studio Code 中,我遇到了变音符号的问题:

在此处输入图像描述

As you see encoding is different between Run and Run Selection of same command: write-host "Wspólny" My JSON user configuration is empty, I've been trying for several hours but no solution helps.如您所见,同一命令的运行和运行选择之间的编码不同: write-host "Wspólny"我的 JSON 用户配置为空,我已经尝试了几个小时,但没有解决方案有帮助。 I want UTF-8 everywhere.我想要 UTF-8 无处不在。

The most likely explanation:最可能的解释:

  • You're running Windows PowerShell , which reads its source code based on the system's active ANSI code page ( 1250 in your example).您正在运行Windows PowerShell ,它根据系统的活动 ANSI 代码页(在您的示例中为1250 )读取其源代码。

  • By contrast, Visual Studio Code creates BOM-less UTF-8 -encoded files by default.相比之下,Visual Studio Code 默认创建无 BOM 的 UTF-8编码文件。

  • In the absence of a BOM in a source code file (or any text file that Windows PowerShell reads, such as with Get-Content ), ANSI encoding is assumed, so the UTF-8 file is misinterpreted .如果源代码文件(或 Windows PowerShell 读取的任何文本文件,例如使用Get-Content )中没有 BOM,则假定为ANSI编码,因此 UTF-8 文件被误解

    • Specifically, each individual byte of any non-ASCII character - which in UTF-8 is always encoded as a multi-byte sequence - is then interpreted as an ANSI character.具体来说,任何非 ASCII 字符的每个单独字节——在 UTF-8 中总是被编码为多字节序列——然后被解释为 ANSI 字符。

    • Note: This is no longer a problem in PowerShell (Core) 7+, which consistently defaults to UTF-8, both on reading BOM-less files and when writing files (BOM-less UTF-8).注意:这在 PowerShell (Core) 7+ 中不再是问题,它始终默认为 UTF-8,无论是在读取 BOM-less 文件时还是在写入文件时(BOM-less UTF-8)。

Therefore, the solution is to save your source code - or any UTF-8 files you want Windows PowerShell to read correctly - as UTF-8 with BOM .因此,解决方案是保存您的源代码- 或您希望 Windows PowerShell 正确读取的任何 UTF-8 文件 -作为ZAE3B3ZDF9970B5BC956727正确读取。

You also need to do this for source code you want to run properly in both editions of PowerShell.您还需要为希望在 PowerShell 的两个版本中正常运行的源代码执行此操作。

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

相关问题 Visual Studio Code - 集成终端 - Ctrl + Z - Visual Studio Code - Integrated Terminal - Ctrl + Z Visual Studio代码终端,如何以管理员权限运行命令? - Visual studio code terminal, how to run a command with administrator rights? Visual Code 集成终端搞砸了 - Visual Code Integrated Terminal messed up 启动Visual Studio 2012 Shell(集成)并使用Windows Scheduler运行SSIS包 - Launch Visual Studio 2012 Shell (Integrated) and run SSIS package using Windows Scheduler 在Visual Studio中作为构建事件运行PowerShell脚本的最简单/最短命令 - Easiest/shortest command to run a PowerShell script as a build event in Visual Studio Visual Studio 代码上的 Julia 是否在 Windows 上运行,速度慢? (Julia 索引 Dateframes 0%...) - Is Julia on Visual Studio code run on windows, slow? (Julia indexing Dateframes 0%...) Visual Studio 代码:运行按钮显示 Python 脚本,但不显示 Ruby - Visual Studio Code: Run button shows for Python Scripts but not for Ruby 如何在 visual studio code 上运行 yarn cammand? - How can run yarn cammand on visual studio code? 无法在 Visual Studio Code 中打开终端 - Unable to open Terminal in Visual Studio Code VS Code - Cygwin 作为集成终端 - VS Code - Cygwin as Integrated Terminal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM