Why is Base64 considered range of ubytes?

Dukc ajieskola at gmail.com
Mon Jun 3 09:13:26 UTC 2019


I just had a range of characters in Base64 I wanted to decode. 
Compiler complained something about no matching template. My 
first reactions were to add `.array` and/or `byCodeUnit` to my 
range. Did not work. Hmm, ensure the range is `char[]` and then 
feed it? Nope. Could it be a regression? Hardly, as this example 
from docs is supposedly unittested:
```
auto encoded = Base64.encoder(cast(ubyte[])"0123456789");
foreach (n; map!q{a - '0'}(Base64.decoder(encoded)))
{
     writeln(n);
}
```

I anyways tested it in a separate project just in case, and it 
complied and worked.

Only after adding `.array` to that first line and changing `auto` 
to `char[]` the problem dawned: `Base64.decoder` does not except 
an input range of characters, it excepts an input range of 
unsigned bytes!

I fail to understand why. Is not the whole point of Base64 to 
encode arbitrary data into readable characters that can be 
unambiquosly written on paper?


More information about the Digitalmars-d mailing list