Proposed Phobos equivalent of wcswidth()

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Jan 16 23:01:19 UTC 2018


On Tue, Jan 16, 2018 at 05:49:11PM +0000, Dmitry Olshansky via Digitalmars-d wrote:
> On Monday, 15 January 2018 at 19:52:07 UTC, H. S. Teoh wrote:
[...]
> > One thing I'm seeking help with, and this is mainly directed at
> > Dmitry Olshansky but can be anyone here who knows the internal
> > workings of std.uni well enough, is how to transform the Trie
> > generated by the static ctor into compile-time TrieNode
> > declarations.  This is one blocker for my turning this code into a
> > Phobos PR, because I don't want to incur the cost of initializing
> > this trie at runtime.
> 
> 
> Checkout my horribly named repo gsoc-uni-benchmark:
> 
> https://github.com/DmitryOlshansky/gsoc-bench-2012/blob/master/gen_uni.d
> 
> This is what generates unicode tables.
> Need to revise it, as folks were delicate enough to hand-patch
> auto-generated code in Phobos.
> 
> Maybe make some of that user-acessible.
[...]

Whoa. There's some pretty cool stuff in there!  Thanks, I've started
experimenting with pre-generating the width table.  Pretty neat. There's
a lot of hidden gems in std.uni that I never knew existed, hidden away
under `private`. :-D

One thing, though: I think it would benefit us all if we could import at
least gen_uni into Phobos, so that in the future when we need to update
std.uni to a new version of Unicode, it can be (mostly) automated.  It's
better to have the tools to generate the tables in Phobos itself, than
to be dependent on an external repo that may go out-of-sync eventually.

When I get around to making a PR for strwidth AKA displayWidth, the plan
is to check-in compileWidth.d in some form into Phobos somewhere, so
that somebody else can pick it up and improve the implementation in the
future if I'm not around / unavailable.

If we can get gen_uni into Phobos, perhaps we can even include the
displayWidth table generation in gen_uni too, so that all the table
generation code is in one place.


T

-- 
Having a smoking section in a restaurant is like having a peeing section in a swimming pool. -- Edward Burr 


More information about the Digitalmars-d mailing list