Take character width into account #25
Replies: 3 comments
-
Looked into the source code and found const wcwidth = require("wcwidth");
const formatter = new Formatter();
formatter.StringLengthFunc = (str) => wcwidth(str); This case can be closed. |
Beta Was this translation helpful? Give feedback.
-
I'm glad you brought this up. I should probably put more about that option in the documentation. In version 2, the string length function was handled with an enum, and the wide-character libraries were hard dependencies. For version 3, I removed the dependencies on particular packages so that people could manage their own versions, etc., and to keep the code smaller for people who didn't need that feature. |
Beta Was this translation helpful? Give feedback.
-
That makes sense 👍 Closing the discussion. |
Beta Was this translation helpful? Give feedback.
-
Apparently the table aligning does not take character width into account.
Current result:
Shoud be:
Could we use wcwidth or similar?
https://www.npmjs.com/package/wcwidth
It would be even better if we could select East Asian Ambiguous Width to 1 or 2, since a lot of CJK environments expect it as 2, but Western environments as 1.
http://www.unicode.org/reports/tr11/#Ambiguous
https://www.npmjs.com/package/meaw
Beta Was this translation helpful? Give feedback.
All reactions