Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HelpBuilder.WriteColumns mismeasures fullwidth CJK characters #1973

Open
KalleOlaviNiemitalo opened this issue Nov 21, 2022 · 1 comment
Open

Comments

@KalleOlaviNiemitalo
Copy link

KalleOlaviNiemitalo commented Nov 21, 2022

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 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 <name>      생성 중인 출력의 이름입니다. 이름을 지정하지 않으면 출
력 디렉터리의 이름이 사용됩니다.
  -o, --output <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 <name>      The name for the output being created. If no name is
                         specified, the name of the output directory is used.
  -o, --output <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.
@KalleOlaviNiemitalo
Copy link
Author

KalleOlaviNiemitalo commented Nov 24, 2022

microsoft/terminal#8000 mentions some complexities of measuring text in a character terminal, but System.CommandLine needs to be portable and cannot examine the glyphs of the font like Windows Terminal can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant