https://issues.dlang.org/show_bug.cgi?id=20140
Issue ID: 20140 Summary: std.string.tr should not be decoding strings Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: bugzi...@digitalmars.com See: https://forum.dlang.org/post/mvkbemmgatrfbxnmj...@forum.dlang.org In the implementation of std.string.tr the main loop is: foreach (dchar c; str) meaning char and wchar strings are getting decoded. This leads to problems as reported on the n.g. link. The correct way to implement it is to just leave it in the encoding of `str`. This should result in a significant speed improvement. This leaves open what to do if `from` and `to` contain invalid UTF sequences if the conversion of them is necessary. The most pragmatic solution is to reject `from` and `to` arguments to `tr` that are not of the same UTF encoding as `str`. --