The Case Against Autodecode

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Tue May 31 13:09:47 PDT 2016


On Tuesday, May 31, 2016 22:47:56 Dmitry Olshansky via Digitalmars-d wrote:
> On 31-May-2016 01:00, Walter Bright wrote:
> > On 5/30/2016 11:25 AM, Adam D. Ruppe wrote:
> >> I don't agree on changing those. Indexing and slicing a char[] is
> >> really useful
> >> and actually not hard to do correctly (at least with regard to
> >> handling code
> >> units).
> >
> > Yup. It isn't hard at all to use arrays of codeunits correctly.
>
> Ehm as long as all you care for is operating on substrings I'd say.
> Working with individual character requires either decoding or clever
> tricks like operating on encoded UTF directly.

Yeah, but Phobos provides the tools to do that reasonably easily even when
autodecoding isn't involved. Sure, it's slightly more tedious to call
std.utf.decode or std.utf.encode yourself rather than letting autodecoding
take care of it, but it's easy enough to do and allows you to control when
it's done. And we have stuff like byChar!dchar or byGrapheme for the cases
where you don't want to actually operate on arrays of code units.

- Jonathan M Davis



More information about the Digitalmars-d mailing list