title: Ruby Base64 encoded picture does not display
body: <p>I'm trying to display a Base64 encoded SVG image in a webpage. The image is encoded using</p>
  
  <pre><code>str = Base64.encode64 '&lt;svg&gt; ... &lt;/svg&gt;'
  </code></pre>
  
  <p>and displayed using</p>
  
  <pre><code>&lt;img src="data:image/svg+xml;base64,"+str &gt;
  </code></pre>
  
  <p>The browser doesn't display the picture. However, if I use the JavaScript btoa() function to encode the string and display it using</p>
  
  <pre><code>$("body").append("img").attr("src", "data:image/svg+xml;base64,"+ btoa("&lt;svg&gt; .. &lt;/svg&gt;"));
  </code></pre>
  
  <p>the image is displayed perfectly.
  There are also a few differences between the Ruby output and the JS output for the same input. I've also tried the strict and urlsafe versions of encode64. Neither of them worked. How do I fix this problem?</p>