[Issue 20140] New: std.string.tr should not be decoding strings
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 18 22:29:00 UTC 2019
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 at puremagic.com
Reporter: bugzilla at 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`.
--
More information about the Digitalmars-d-bugs
mailing list