E.S. Quinn
E.S. Quinn
Specifically, it's concatenating strings (or anything that allocates from the heap). As I understand it, it's not part of the language spec, but it's one of the quirks of the...
Like the comment mentions; I was v. inexperienced with treating strings as ranges, and I tried returning the traditional "this is invalid unicode" character, but it made things mess up...
This code saves on allocations if the user isn't storing their string data in a dchar[], because it's converting the char[] to dchars every time. IF the user's data is...
Since an individual char is implicitly convertible to dchar, it'll take a range of char. Then the decodeHead/safeDecode takes as many characters as necessary off the front of a char...
Nope, it works for wchar too! (Albeit, with all the various caveats that wchar brings with it. Hissss. we hateses wchar, precious.)
Yeah, safeDecode is the big thing that's wrong with that code. (There may also be other issues but I'm hardly a master of ranges either)
Honestly I'm not sure! To me personally, it's more intuitive, when dealing with unicode errors, to print an invalid character glyph and move on? But I can also see wanting...
(Because having a � in output _is_ a pretty visible thing, so it's not exactly hiding bugs.)
That's reasonable, though given that D has the facilities to handle it, I'd alternately recommend falling back to \uFFFD, since that is the unicode-designated character for "I can't print this."...
Blight it all, safeDecode won't work with just a forward range. It's telling us it needs a Random Access Range (the [] overload) with the .length property. The thing with...