Fix Phobos dependencies on autodecoding
Vladimir Panteleev
thecybershadow.lists at gmail.com
Thu Aug 15 14:02:34 UTC 2019
On Thursday, 15 August 2019 at 12:09:02 UTC, Vladimir Panteleev
wrote:
> I haven't looked into that, perhaps someone more familiar with
> std.regex and std.uni could have a look.
In std.uni, there is genericDecodeGrapheme, which needs to:
1. Work with strings of any width
2. Work with input ranges of dchars
3. Advance the given range by ref
With autodecoding on, the first case is handled by .front /
.popFront.
With autodecoding off, there is no direct equivalent any more.
The problem is that the function needs to peek ahead (which can
be multiple range elements for ranges of narrow char types, which
is not possible for input ranges).
- Replacing .front / .popFront with std.utf.decodeFront does not
work because the function does not do these operations in the
same place, so we need to save the range before decodeFront
advances it, but we can't .save() input ranges from case 2 above.
- Using byDchar does not work because .byDchar does not take its
range by ref, so advancing the byDchar range will not advance the
range passed by ref to genericDecodeGrapheme. I tried to use
std.range.refRange for this but hit a compiler ICE ("precedence
not defined for token 'cantexp'").
Perhaps there is already a construct in Phobos that can solve
this?
More information about the Digitalmars-d
mailing list