Skip to content
New issue

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

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

Already on GitHub? # to your account

Support unicode chars in WriteHelp #401

Open
JasonMing opened this issue Jan 16, 2024 · 1 comment
Open

Support unicode chars in WriteHelp #401

JasonMing opened this issue Jan 16, 2024 · 1 comment

Comments

@JasonMing
Copy link

WriteHelp function will auto wrap and align the description that longer than terminal's width.
When multi-byte character in the description, like emoji or Chinese, the wrapping will be wrong.

func main() {
	var opt struct {
		WorkerId uint64 `short:"w" long:"worker" description:"01234567891123456789212345678931234567894123456789512345678961❤3456789"`
	}

	p := flags.NewParser(&opt, flags.HelpFlag|flags.PrintErrors)
	p.WriteHelp(os.Stdout)
}

Output:

Usage:
  example [OPTIONS]

Application Options:
  -w, --worker= 01234567891123456789212345678931234567894123456789512345678961�-

                ��3456789
@rasa
Copy link

rasa commented Dec 10, 2024

@JasonMing I'm unable to duplicate this issue in Linux, and Windows 11. In a Command Prompt window on Windows 11, the heart is there, but isn't red. In a Windows Terminal window, the heart is there.

Even inside an ssh session on Windows, the heart appears ok (albeit it shows as grey, not red).

What OS/version/terminal app are you running this code on?

package main

import (
	"os"
	"github.com/jessevdk/go-flags"
)

func main() {
	var opt struct {
		WorkerId uint64 `short:"w" long:"worker" description:"01234567891123456789212345678931234567894123456789512345678961❤3456789"`
	}

	p := flags.NewParser(&opt, flags.HelpFlag|flags.PrintErrors)
	p.WriteHelp(os.Stdout)
}

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

No branches or pull requests

2 participants