Can't call `each` on `retro` with *some* functions

yabobay someone at example.com
Sun Dec 14 13:40:29 UTC 2025


On Sunday, 14 December 2025 at 12:43:57 UTC, Paul Backus wrote:
> On Sunday, 14 December 2025 at 12:32:23 UTC, yabobay wrote:
>> [...]
>
> This is caused by [autodecoding][1], a feature of the standard 
> library where strings are automatically converted into Unicode 
> code points when used as ranges.
>
> Because UTF-8 is a variable-length encoding, this means that 
> when a UTF-8 `string` is used as a range, it does not have a 
> `.length` property (read the linked article for a more thorough 
> explanation).
>
> You can work around this using `std.utf.byCodeUnit` to treat 
> the string as a range of bytes instead of a range of code 
> points:
>
> ```d
> import std.utf : byCodeUnit;
>
> s.byCodeUnit.retro.each!(...); // No error
> ```
>
> [1]: https://jackstouffer.com/blog/d_auto_decoding_and_you.html

Thanks! I also found that making the `SList` be of `dchar`'s 
instead of `char`'s also works and is closer to what i wanted to 
do in the first place.


More information about the Digitalmars-d-learn mailing list