Searching strings with indexOf vs countUntil

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 25 05:46:43 PDT 2017


On Thursday, 25 May 2017 at 11:55:21 UTC, Kagamin wrote:
> I would guess indexOf returns a value suitable for indexing, 
> therefore it counts code units, while countUntil counts range 
> elements - code points in case of a string. Also number of code 
> points is not suitable for indexing an utf8 string, it can be 
> used to allocate a dstring, but not so much for anything else. 
> What do you use the resulting value for?

To get rid of decoding he can cast to ubyte[]. I would do that if 
sure that the input is only made of ascii chars.


More information about the Digitalmars-d-learn mailing list