The problem is that you are using Unicode, which uses a variable number of bytes to store a character: some will be one byte, some will be 2, and so on. Alphabetic characters are generally one byte, but DEL is likely to be several.
So reading a string into a string at an index is ... going to be problematic.
Instead, read your replacement string into a new instance of std::string then use string::substr - C++ Reference
] to extract both the leading and tailing data from your original input and then assemble a new string from teh three new pieces:
Replace at index: 2
New string = S1 + Replacement + S2