www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Bast64URL Error; Invalid character

reply xky <despair4045 nate.com> writes:
Hi! First, thank you to those who always answers.

I got some DataURL string(it's png image) like this...
================================================================================
<img src="data:image/png;base64,iVBORw0KGgoAAAA... blah blah 
blah... example==" style="position: absolute; height: 100%; 
width: 100%;" height="1080" width="750">
================================================================================





So, i used std.base64 library, and this is my test code.
================================================================================
import std.stdio;
import std.base64;

void main()
{
   string data = "iVBORw0KGgoAAAA... blah blah blah... example==";
   auto bin = Base64URL.decode( data );

   File f = File("index.png", "wb");
   f.rawWrite(bin);
   f.close();
}
================================================================================





And... get this error.
================================================================================
std.base64.Base64Exception C:\D\dmd2\windows\bin\..\..\src\phobos
std\base64.d(1690): Invalid character: +
================================================================================





I tried finding "+" character, but i coudn't find it at original 
dataurl.
What is my problem?

Regards,
Jun 04 2016
parent xky <despair4045 nate.com> writes:
On Saturday, 4 June 2016 at 15:27:53 UTC, xky wrote:
 Hi! First, thank you to those who always answers.

 I got some DataURL string(it's png image) like this...
 ================================================================================
 <img src="data:image/png;base64,iVBORw0KGgoAAAA... blah blah 
 blah... example==" style="position: absolute; height: 100%; 
 width: 100%;" height="1080" width="750">
 ================================================================================

 [...]
Oh, I make mistakes. "+" Character is in the data URL scheme. But the error is still. Thanks.
Jun 04 2016