dotnet / dotnet/command-line-api
HelpBuilder.WriteColumns mismeasures fullwidth CJK characters
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
HelpBuilder.WriteColumns assumes that each UTF-16 `char` takes up one character cell in the terminal, but this assumption does not hold for fullwidth characters used in Chinese, Japanese, and Korean. Fixing this needs a character-width lookup similar to the [wcwidth](https://www.man7.org/linux/man-pages/man3/wcwidth.3p.html) function.
Help in Korean is incorrectly wrapped by .NET SDK 7.0.100 on Windows Terminal Preview 1.16.2641.0, code page 65001, 80-column window:
```
C:\>SET DOTNET_CLI_UI_LANGUAGE=ko-KR
C:\>chcp 65001
Active code page: 65001
C:\>dotnet new globaljson --help
global.json 파일
작성자 :Microsoft
설명: .NET SDK 버전을 선택하기 위한 파일입니다.
Usage:
dotnet new globaljson [options] [템플릿 옵션]
Options:
-n, --name 생성 중인 출력의 이름입니다. 이름을 지정하지 않으면 출
력 디렉터리의 이름이 사용됩니다.
-o, --output 생성된 출력을 배치할 위치입니다.
--dry-run 템플릿이 생성될 경우 주어진 명령 줄이 실행되면 어떤 일
이 발생하는지에 대한 요약을 표시합니다.
````
(deleted the rest of the output)
In contrast, output in en-US is correctly wrapped:
```
C:\>dotnet new globaljson --help
global.json file
Author: Microsoft
Description: A file for selecting the .NET SDK version.
Usage:
dotnet new globaljson [options] [template options]
Options:
-n, --name The name for the output being created. If no name is
specified, the name of the output directory is used.
-o, --output Location to place the generated output.
--dry-run Displays a summary of what would happen if the given
command line were run if it would result in a template
creation.
```
Contributor guide
Assessment
This issue has not been assessed yet.