Thread overview |
---|
November 27, 2010 Base64 - Encoding and decoding | ||||
---|---|---|---|---|
| ||||
Hey guys, I want encode and decode binary files like images, documents and similar file types to use it in an binary xml. For those I created a simple command line tool which encode or decode an file. The encoding of files will be processed by these lines: ... ubyte[] buffer; buffer.length = source.available(); source.read(buffer); string content; for (uint i = 0; i < buffer.length; i++) { content ~= to!(char)(buffer[i]); } destination.write(encode(content)); ... This seems to work correctly, but when I want decode the file, I always get "std.base64.Base64CharException: Invalid base64 character". I'm currently using the following to decode the file: char[] content; for (uint i = 0; i < source.available(); i++) { content ~= source.getc(); } decode(to!(string)(content)); But... when I directly decode the encoded (without read the encoded content from external file), the decoded file is valid. I hope anyone know where's my mistake :) Thanks! |
November 28, 2010 Re: Base64 - Encoding and decoding | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nrgyzer | Nrgyzer Wrote:
> decode(to!(string)(content));
check out, what you send to decode function.
the code... /3_=
|
Copyright © 1999-2021 by the D Language Foundation