Fix issue 12890 - index based replace

https://issues.dlang.org/show_bug.cgi?id=12890

EDIT:
I'm going to split this up into two pull request to make review of insert and replace independent (and thus more manageable.)
I'm in the process of reviewing the code, don't pull. It's a PR so it doesn't fall off the radar.
This is a mess.
Also replace does assumes codeunit indices, not codepoint ones. So slicing was correct.