Advent of Code 2019

Uknown sireeshkodali1 at
Mon Nov 25 11:51:41 UTC 2019

On Monday, 25 November 2019 at 11:32:38 UTC, Sergei Nosov wrote:
> On Saturday, 23 November 2019 at 04:38:14 UTC, mipri wrote:
>> [snip]
> I've only made it halfway through last year.
> One of the unexpected difficulties for me was, actually, 
> working with strings. The problems involve only ASCII 
> characters, so you don't care about the UTF stuff at all. Yet, 
> D always tries to be cautious of it and you have to workaround 
> it all the time which leads to ugly-looking hacks, like 
> What would be a recommended way to handle such cases? (i.e. 
> when you know for sure that your characters are always 8-bit, 
> so it's safe to call `sort`, `toUpper` and all the other std 
> functions without ever trying to decode)

Use `std.string.representation` to bypass autodecoding. It just 
casts the string to `ubyte[]` which is what you need most of the 
time. Then case back to string as necessary with `assumeUTF`.

More information about the Digitalmars-d mailing list