Bug 20140 – std.string.tr should not be decoding strings

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-08-18T22:29:00Z
Last change time
2024-12-01T16:35:27Z
Assigned to
No Owner
Creator
Walter Bright
Moved to GitHub: phobos#10383 →

Comments

Comment #0 by bugzilla — 2019-08-18T22:29:00Z
See: https://forum.dlang.org/post/[email protected] 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`.
Comment #1 by robert.schadek — 2024-12-01T16:35:27Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10383 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB