D-Programming-Language/phobos — pull request #1736 by JakobOvrum (2013-11-29 09:35:19+00:00)
Title: Add std.uni.byGrapheme and std.uni.byCodePoint

Considered in response to the [Unicode handling comparison](http://forum.dlang.org/thread/nieoqqmidngwoqwnktih@forum.dlang.org) thread on the NewsGroup.

* `byGrapheme` eases string manipulation on graphemes by allowing range algorithms to work with graphemes rather than code points.

* `byCodePoint` is a counterpart necessary for converting the result of range-based string manipulation on graphemes back to a string. e.g. `graphemes.byCodePoint.text` converts a range of graphemes to a `string`, and `graphemes.byCodePoint.array` converts a range of graphemes to a `dchar[]`. Of course, it's also useful on its own when a range of code points is accepted, such as when doing I/O: ```D writeln(graphemes.byCodePoint);```

The result needs to use `array` before `retro` because `byGrapheme` is only a `ForwardRange`. Bidirectionality is technically possible to add, but `byGrapheme` simply builds on existing `std.uni` functionality (i.e. `decodeGrapheme`), which does not seem to support decoding graphemes from the back of a string.

If bidirectionality is added to `byGrapheme`, then `byCodePoint` should be edited to propagate it when available.

@blackwhale (and others), please destroy.