【问题标题】:ddev on PowerShell on Windows Japanese UTF-8ddev on PowerShell on Windows Japanese UTF-8
【发布时间】:2021-09-07 00:09:40
【问题描述】:
日文 Win10 系统在 powershell 和 git-bash 中的 DDEV 和 UTF8 输出存在问题。
ddev list 在表格行的末尾显示一个截断标记 (=),尽管窗口大小足以容纳整个表格。
这发生在下面,尽管它们之间的确切断点略有不同。
- Windows Powershell 5.1.19041.1151 本机窗口
- Powershell Core 7.1.4 本机窗口
- 通过 Windows 终端的 Window Powershell 和 Powershell Core
- 通过 Windows 终端执行 Git-bash
truncated table
这个问题最初被跟踪#3218和#2965
【问题讨论】:
标签:
powershell
utf-8
windows-10
ddev
【解决方案1】:
此答案是解决方案的集合,集中用于帮助他人。
在讨论here 和here 的CJK 语言系统上的“外部”程序中似乎存在一个已知的UTF8 错误。
解决方案:Windows Powershell 5.1.19041.1151
# Get profile path
echo $profile
[home]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
[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
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
解决方案:git-bash (minntty 3.5.0)
- 本机 git-bash 开箱即用,但通过 Windows 终端运行时出现问题。
- 此问题已在 here 讨论过,用日语
- 将以下行添加到
~/.bash_profile
# Explicitly set UTF-8 encoding
chcp.com 65001