hyiso / string_width Goto Github PK
View Code? Open in Web Editor NEWGet the visual width of a string - the number of columns required to display it
Home Page: https://pub.dev/packages/string_width
License: Apache License 2.0
Get the visual width of a string - the number of columns required to display it
Home Page: https://pub.dev/packages/string_width
License: Apache License 2.0
I've noticed that some characters have different widths based on the Unicode version of the terminal. Would it make sense to make this package handle multiple Unicode versions by passing in a Unicode version argument?
I was trying out your project and found that the "heart hands" emoji 🫶 was reported as 1 in width even though it takes up two spaces in my terminal. It's part of Unicode 14.
Squares ▪︎▫︎◻︎◼︎ and arrows ◀︎▶︎ reported with width 2 but only takes up 1 space in the terminal.
There are probably more cases like this. i Pressed the "Character viewer" on my mac and went to "Bullets and stars" to find these.
The following line is quite performance expensive after doing some profiling:
input = input.replaceAll(emojiRegex(), ' ');
Regarding my comment on #2 i thought i make a separate issue for this.
The following code line replaces all emoji characters with two empty spaces which returns a width of 2 as far as i can see. Is this correct behavior, or a naive implementation?
input = input.replaceAll(emojiRegex(), ' ');
As i mentioned in #2 , the black square only takes up 1 space in the terminal whilst still being replaced in the emojiRegex
call.
As I've learned there are lots of things determining the width of a rendered character, like the Terminal, Font, Unicode version etc. Maybe you could elaborate on the scope or correctness of this method / package.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.