Thread overview
[Issue 17810] Add wcwidth/wcswidth equivalents to std.uni
Sep 08, 2017
Dmitry Olshansky
Sep 09, 2017
Jonathan M Davis
Sep 09, 2017
Jon Degenhardt
Sep 09, 2017
Richard Cattermole
Dec 17, 2022
Iain Buclaw
September 08, 2017
https://issues.dlang.org/show_bug.cgi?id=17810

Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|nobody@puremagic.com        |dmitry.olsh@gmail.com

--
September 09, 2017
https://issues.dlang.org/show_bug.cgi?id=17810

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #1 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
Given that this is tied to the terminal, I wouldn't really expect this in std.uni, which is focused on implementing the Unicode standard, not on system-specific stuff like this or really anything with how the characters will actually look like when dispayed. I also don't know if an equivalent is available on Windows, and in general, we try to have the stuff in Phobos be crossplatform. So, I'm inclined to think that that these are not appropriate for std.uni. But regardless of all of that, these functions should have bindings in druntime so that they can easily be called on the systems that do have them, and those seem to missing right now, which should be fixed. So, I think that the appropriate thing would be to just call them directly rather than doing something in Phobos, but obviously the bindings will have to be added for that to work.

--
September 09, 2017
https://issues.dlang.org/show_bug.cgi?id=17810

--- Comment #2 from Jon Degenhardt <jrdemail2000-dlang@yahoo.com> ---
(In reply to Jonathan M Davis from comment #1)

I didn't intend the "POSIX" part of the enhancement request as literally as it came out. The 'width' characteristic part of the unicode standard, and comes with the unicode character database. See: http://unicode.org/reports/tr11/. It is not tied to the terminal or Windows. Exposing the system implementation of 'wcwidth' would of course be environment specific, but implementing it based on the unicode tables would not be.

For these reasons, I do think it is legitimate functionality to support in std.uni.

At the same time, there is a strong argument that this be considered a low-priority enhancement. My searches didn't find other D users requesting this. And, it's only useful in fixed-width fonts. I'd certainly use it in the code I'm writing, but I'm finding I can get acceptable estimates with the cheap trick of assuming all CJK characters have width two.

--
September 09, 2017
https://issues.dlang.org/show_bug.cgi?id=17810

Richard Cattermole <alphaglosined@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alphaglosined@gmail.com

--- Comment #3 from Richard Cattermole <alphaglosined@gmail.com> ---
We have the full Unicode database in Phobos. It needs updating and exposing (since this request is asking for one more part of it).

--
January 13, 2018
https://issues.dlang.org/show_bug.cgi?id=17810

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--
January 13, 2018
https://issues.dlang.org/show_bug.cgi?id=17810

--- Comment #4 from hsteoh@quickfur.ath.cx ---
We don't need to rely on the local OS implementation of this function; std.uni has enough tools to provide a native implementation. Also, this is independent of Posix, even though wcwidth/wcswidth are the names under which the Posix standard provides this functionality; Unicode TR11 specifies an East Asian Width property for characters. The data file can be obtained here:

ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt

Here's a tentative implementation that I made using std.uni's Trie facilities:

https://github.com/quickfur/strwidth

I hope to get this into shape to add to std.uni at some point.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=17810

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 01
https://issues.dlang.org/show_bug.cgi?id=17810

--- Comment #5 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10263

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--