Re: <iframe doc="">

On Sun, 24 Jan 2010 17:41:42 -0500, Tab Atkins Jr. <>  

> The answer, by the way, is no.  I can't speak for other languages, but
> PHP's standard url escaping function, urlencode(), will escape spaces
> as +.  data: urls require spaces to be encoded as %20.

In JS, data: is as easy as:

<meta charset="utf-8">
"data:text/html;charset=utf-8," + encodeURIComponent(s);

"data:text/html;charset=utf-8;base64, +  

(optionally doing s.replace(/\r\n|\r|\n/g, "\r\n") to normalize newlines  
first. Technically, for the first one, I think you are encouraged to do  
that so the URI is representing newlinews as %0D%0A and not juse %0A for  
example. Some URI validator might even warn you if you don't.)

For the second one, you still have to do the encodeURIComponent just in  
case any chars in the base64 string need to be percent-encoded. It's  
usually just a few though, but you still have to do it.

And, as Thomas mentioned, for php, rawurlencode/decode are basically  
always used for non-http stuff (like mailto for example) so '+' doesn't  
get confused with ' '. But, you're right. Many, many people mistakenly use  
just urlencode/decode, even seasoned developers that normally only work  
with HTTP URIs.


Received on Monday, 25 January 2010 08:40:44 UTC