-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[String] Made AbstractString::width() follow POSIX.1-2001 #35156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dd7eb72
to
eba29c0
Compare
eba29c0
to
274edfc
Compare
a7fa164
to
3c6e292
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that looks good to me.
I pushed a second commit that makes the most important changes I think we should do.
Namely, we don't want to add a new method, but to improve the existing one.
That's why I made wcwidth()
private, and use it in width()
.
Of course, I didn't finish the refacto so tests won't pass anymore :P
6ecc13e
to
495d959
Compare
@nicolas-grekas Could we however somehow have a public accessible pure implementation of wcswidth in the String component? With moving the wcswidth() method logic somewhere else for example. Symfony wcswidth implementation could become the most robust tested PHP implementation. |
Honestly, I'm not sure until someone gives us a real-world use case... width() looks more useful to me... |
bd8e0b3
to
25b3499
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(with minor comments)
25b3499
to
4967e13
Compare
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
4967e13
to
347d825
Compare
Thank you @fancyweb. |
…001 (fancyweb) This PR was merged into the 5.1-dev branch. Discussion ---------- [String] Made AbstractString::width() follow POSIX.1-2001 | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This PR ports the wcswidth() function (see http://man7.org/linux/man-pages/man3/wcwidth.3.html and https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c) into the String component. This new method will be useful in the Console component to determine how many columns a character takes. I kind of copied the Intl data import strategy. Commits ------- 347d825 [String] Made AbstractString::width() follow POSIX.1-2001
This PR ports the wcswidth() function (see http://man7.org/linux/man-pages/man3/wcwidth.3.html and https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c) into the String component. This new method will be useful in the Console component to determine how many columns a character takes.
I kind of copied the Intl data import strategy.