<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MixInformatico.com &#187; JavaScript</title>
	<atom:link href="http://www.mixinformatico.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mixinformatico.com</link>
	<description>Reforzando tus ideas</description>
	<lastBuildDate>Sat, 31 Jul 2010 00:47:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Javascript – urlencode</title>
		<link>http://www.mixinformatico.com/2010/05/09/javascript-%e2%80%93-urlencode/</link>
		<comments>http://www.mixinformatico.com/2010/05/09/javascript-%e2%80%93-urlencode/#comments</comments>
		<pubDate>Mon, 10 May 2010 02:50:00 +0000</pubDate>
		<dc:creator>dementexmaster</dc:creator>
				<category><![CDATA[Html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Javascript – urlencode]]></category>
		<category><![CDATA[urlencode]]></category>

		<guid isPermaLink="false">http://www.mixinformatico.com/?p=9243</guid>
		<description><![CDATA[Hay veces en que la función de javascript escape() no es suficiente, como por ejemplo si hay que codificar ‘?’. No sé exactamente cuando ni donde encontré esta función que imita el urldecode de PHP pero migrada a javascript, espero que les sea tan útil como a mi. 1 2 3 4 5 6 7 [...]]]></description>
			<content:encoded><![CDATA[<p>Hay veces en que la función de <strong>javascript </strong><strong>escape()</strong> no es suficiente, como por ejemplo si hay que codificar ‘?’. No sé  exactamente cuando ni donde encontré esta función que imita el <strong>urldecode </strong>de PHP pero migrada a <strong>javascript</strong>, espero que les sea tan útil como a mi.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span> str <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">var</span> histogram <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> histogram_r <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> code <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> tmp_arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">var</span> ret <span style="color: #339933;">=</span> str<span style="color: #339933;">.</span>toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">var</span> replacer <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>search<span style="color: #339933;">,</span> replace<span style="color: #339933;">,</span> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">var</span> tmp_arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 tmp_arr <span style="color: #339933;">=</span> str<span style="color: #339933;">.</span><span style="color: #990000;">split</span><span style="color: #009900;">&#40;</span>search<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">return</span> tmp_arr<span style="color: #339933;">.</span><span style="color: #990000;">join</span><span style="color: #009900;">&#40;</span>replace<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// The histogram is identical to the one in urldecode.</span>
 histogram<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'!'</span><span style="color: #009900;">&#93;</span>   <span style="color: #339933;">=</span> <span style="color: #0000ff;">'%21'</span><span style="color: #339933;">;</span>
 histogram<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'%20'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'+'</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Begin with encodeURIComponent, which most resembles PHP's encoding functions</span>
 ret <span style="color: #339933;">=</span> encodeURIComponent<span style="color: #009900;">&#40;</span>ret<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>search in histogram<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 replace <span style="color: #339933;">=</span> histogram<span style="color: #009900;">&#91;</span>search<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 ret <span style="color: #339933;">=</span> replacer<span style="color: #009900;">&#40;</span>search<span style="color: #339933;">,</span> replace<span style="color: #339933;">,</span> ret<span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Custom replace. No regexing</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Uppercase for full PHP compatibility</span>
 <span style="color: #b1b100;">return</span> ret<span style="color: #339933;">.</span>replace<span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">%</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>z0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>g<span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>full<span style="color: #339933;">,</span> m1<span style="color: #339933;">,</span> m2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;%&quot;</span><span style="color: #339933;">+</span>m2<span style="color: #339933;">.</span>toUpperCase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #b1b100;">return</span> ret<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.mixinformatico.com/2010/05/09/javascript-%e2%80%93-urlencode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.347 seconds -->

