How to code Z-Function of string?

MoonlightSentinel moonlightsentinel at disroot.org
Thu Mar 26 23:55:17 UTC 2020


On Thursday, 26 March 2020 at 19:34:08 UTC, Quantium wrote:
>     string s="abc";
>     writeln(s[1]); // Should write 'b' or not???
> Is it a legit code or it doesn't work ?

Yes, but keep in mind that char[] implies UTF8. Hence this won't 
work if your input contains e.g. chinese characters.

Refer to std.utf (https://dlang.org/phobos/std_utf.html) for some 
utilities to deal with UTF.


More information about the Digitalmars-d-learn mailing list