digitalmars.D.bugs - [Issue 20140] New: std.string.tr should not be decoding strings
- d-bugmail puremagic.com (25/25) Aug 18 2019 https://issues.dlang.org/show_bug.cgi?id=20140
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: nobody puremagic.com Reporter: bugzilla digitalmars.com See: https://forum.dlang.org/post/mvkbemmgatrfbxnmjada 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`. --
Aug 18 2019