laravel / prompts

Beautiful and user-friendly forms for your command-line PHP applications.
https://laravel.com/docs/prompts
MIT License
533 stars 94 forks source link

Multi-byte characters make the right border position incorrect #29

Closed crazywhalecc closed 1 year ago

crazywhalecc commented 1 year ago

Laravel Prompts Version

v0.1.1 (I also tested dev-main)

Laravel Version

Independent installation of prompts

PHP Version

8.2.8

Operating System & Version

macOS 13.0

Terminal Application

Terminal

Description

When I input multi-byte characters (such as Chinese, Japanese, Emoji, etc.), the width of the border at the end changes. These multibyte characters occupy 2 spaces, but the calculation boundary may use its actual length (3 spaces).

Maybe using mb_strwidth to solve this?

Steps To Reproduce

image image
jessarcher commented 1 year ago

Hey @crazywhalecc,

TIL about mb_strwidth! Thank you! I've been using mb_strlen, which works fine for single-width multibyte characters like accents, but not emojis, etc.

I'll have a play around and hopefully get something together very soon.

tyler36 commented 1 year ago

Came across this using Japanese with Prompt 0.1.3 on WSL.

prompt

jessarcher commented 1 year ago

Continuing the discussion over at #33