Windows 日文 UTF-8 上 PowerShell 上的 ddev

ddev on PowerShell on Windows Japanese UTF-8

日文 Win10 系统在 powershell 中的 DDEV 和 UTF8 输出存在问题 & git-bash.

ddev list 在 table 行的末尾显示截断标记 (=),尽管 window 大小足以包含完整的 [=42] =].

这发生在下面,尽管它们之间的确切断点略有不同。

truncated table

这个问题最初被跟踪 #3218 and #2965

此答案是 collection 解决方案,集中的,以帮助他人。

here and here.

讨论的 CJK 语言系统上的 'external' 个程序似乎有一个已知的 UTF8 错误

解决方案:Windows Powershell 5.1.19041.1151

# Get profile path
echo $profile
[home]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
  • 所有编码明确使用UTF8
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
  • 重新启动终端以应用设置

解决方案:Powershell Core 7.1.4

  • 同上,但配置文件会有所不同;通常 [home]\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
# Get profile path
echo $profile
[home]\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
  • 所有编码明确使用UTF8
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
  • 重新启动终端以应用设置

解决方案:git-bash (minntty 3.5.0)

  • 本机 git-bash 工作 out-of-the-box 但是当 运行 通过 Windows 终端时问题出现了。
  • 此问题已用日语here讨论
  • 将以下行添加到 ~/.bash_profile
# Explicitly set UTF-8 encoding
chcp.com 65001