Search code examples
powershellutf-8windows-10ddev

ddev on PowerShell on Windows Japanese UTF-8


There is an issue with DDEV and UTF8 output on Japanese Win10 systems in powershell & git-bash.

ddev list displays an truncated mark (=) at the end of table lines on dispite the window size being big enough to contain the full table.

This occurs in the following although the exact breakpoint varies slightly between them.

  • Windows Powershell 5.1.19041.1151 native window
  • Powershell Core 7.1.4 native window
  • Window Powershell & Powershell Core via Windows Terminal
  • Git-bash via Windows Terminal

truncated table

This issue was originally tracked #3218 and #2965


Solution

  • This answer is a collection of solutions, centralized, to help others.

    There seems to be a known bug with UTF8 from 'external' programs on CJK language systems discussed here and here.

    Solution: Windows Powershell 5.1.19041.1151

    • Confirm that Powershell is indeed set to UTF-8 via Windows PowerShell properties, right-click title bar and select properties
    • Get the active profile file path via a Powershell terminal
    # Get profile path
    echo $profile
    [home]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
    
    • Explicitly use UTF8 for all encoding
    [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
    
    • Restart terminal to apply setting

    Solution: Powershell Core 7.1.4

    • Same as above but the profile file will be different; usually [home]\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
    # Get profile path
    echo $profile
    [home]\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
    
    • Explicitly use UTF8 for all encoding
    [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
    
    • Restart terminal to apply setting

    Solution: git-bash (minntty 3.5.0)

    • Native git-bash worked out-of-the-box but when when run via Windows Terminal the issue appeared.
    • This issue was discussed here, in Japanese
    • Add the following line to ~/.bash_profile
    # Explicitly set UTF-8 encoding
    chcp.com 65001