[phobos] std.base64 replacement
Daniel Murphy
yebblies at gmail.com
Tue Oct 12 19:49:40 PDT 2010
Ok, here's a first attempt.
http://yebblies.com/rangebase64.d
I ran into a couple of issues along the way:
Taking strings as input doesn't work properly, as string and wstring are
defined not to have a length. I'm not sure whether to special case them and
assume they contain only ascii characters or not. At the moment it only
accepts ubyte ranges.
This makes me think we _really_ need a AsciiString type in phobos, possibly
with a matching assumeAscii function that checks the characters used when in
debug mode. Does anyone think this would be a good idea?
Decoder cannot provide length when padding is used without examining the end
of the input. Currently decoder on a forward range scans to then end of the
range, giving the constructor complexity of O(n). Is this acceptable?
Is there any point in making Encoder/Decoder bidirectional/random access?
As a side issue, would anyone else find a range that exposes the raw bytes
of another range useful?
auto x = [0xFFEEDDCC, 0xBBAA9988];
assert(equal(rawBytes(x), [0xCC, 0xDD, 0xEE, 0xFF, 0x88, 0x99, 0xAA, 0xBB]);
This allows you to pass any range of POD types into Base64.encode or any
similar range.
Daniel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20101013/b8bc0c20/attachment.html>
More information about the phobos
mailing list