dotnet / dotnet/command-line-api

HelpBuilder.WriteColumns mismeasures fullwidth CJK characters

Offen
#1,973 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C#
Sterne
3.7k
Forks
428
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne bei HelpBuilder.WriteColumns und reproduziere das koreanische Beispiel mit DOTNET_CLI_UI_LANGUAGE=ko-KR in einem Terminal mit 80 Spalten. Vergleiche die Ausgabe mit en-US und untersuche die im Issue verlinkte wcwidth-Referenz. Erledigt ist die Aufgabe, wenn vollbreite CJK-Zeichen entsprechend der Terminalzellbreite umgebrochen werden, ohne das bestehende englische Layout zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.