How to make rsplit (like in Python) in D
Uranuz via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 3 12:40:54 PDT 2016
On Saturday, 1 October 2016 at 18:33:02 UTC, TheFlyingFiddle
wrote:
> On Saturday, 1 October 2016 at 16:45:11 UTC, Uranuz wrote:
>> [...]
>
> There are two reasons why this does not compile. The first has
> to do with how retro() (and indeed most function in std.range)
> work with utf-8 strings (eg the string type). When working on
> strings as ranges, the ranges internally change the type of
> ".front" from 'char' into 'dchar'. This is done to ensure that
> algorithms working on strings do not violate utf-8.
>
> [...]
Thanks for clarification. It seems that once upon a time I'll
write my own string wrapper that will return just slice of
`string` pointing to source multibyte sequence as .front and will
use it, and be happy. When I looking more at other languages
(like Python) then I more convinced that working with UTF-8
string as array of single bytes is not very good
More information about the Digitalmars-d-learn
mailing list