<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: String.toCharCode</title>
	<atom:link href="http://readystate4.com/2008/10/27/stringtocharcode/feed/" rel="self" type="application/rss+xml" />
	<link>http://readystate4.com/2008/10/27/stringtocharcode/</link>
	<description>JavaScript, Web Development, Ruby, and Technology.</description>
	<lastBuildDate>Sun, 06 Jun 2010 14:40:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Heironymus P. Organthruster</title>
		<link>http://readystate4.com/2008/10/27/stringtocharcode/comment-page-1/#comment-1026</link>
		<dc:creator>Heironymus P. Organthruster</dc:creator>
		<pubDate>Tue, 09 Mar 2010 12:39:54 +0000</pubDate>
		<guid isPermaLink="false">http://readystate4.com/2008/10/27/stringtocharcode/#comment-1026</guid>
		<description>all versions of IE 6.x and greater barf at:

String.charCodeAt(str[i]);

whereas

str[i].charCodeAt(0);

seems to keep them happy.</description>
		<content:encoded><![CDATA[<p>all versions of IE 6.x and greater barf at:</p>
<p>String.charCodeAt(str[i]);</p>
<p>whereas</p>
<p>str[i].charCodeAt(0);</p>
<p>seems to keep them happy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mauvis</title>
		<link>http://readystate4.com/2008/10/27/stringtocharcode/comment-page-1/#comment-918</link>
		<dc:creator>Mauvis</dc:creator>
		<pubDate>Sun, 16 Nov 2008 09:40:31 +0000</pubDate>
		<guid isPermaLink="false">http://readystate4.com/2008/10/27/stringtocharcode/#comment-918</guid>
		<description>I agree that as a general utility function it should return an array for greater control and to do that you would just &lt;code&gt;return work;&lt;/code&gt; instead of &lt;code&gt;return work.join(&#039;,&#039;);&lt;/code&gt;

However, for the situations I needed it I just needed a string.</description>
		<content:encoded><![CDATA[<p>I agree that as a general utility function it should return an array for greater control and to do that you would just <code>return work;</code> instead of <code>return work.join(',');</code></p>
<p>However, for the situations I needed it I just needed a string.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Vold</title>
		<link>http://readystate4.com/2008/10/27/stringtocharcode/comment-page-1/#comment-917</link>
		<dc:creator>Erik Vold</dc:creator>
		<pubDate>Sun, 16 Nov 2008 05:59:11 +0000</pubDate>
		<guid isPermaLink="false">http://readystate4.com/2008/10/27/stringtocharcode/#comment-917</guid>
		<description>Hey, nice function, but I was thinking, maybe it should return an array, as the input used by fromCharCode is an array.

What do you think?

E</description>
		<content:encoded><![CDATA[<p>Hey, nice function, but I was thinking, maybe it should return an array, as the input used by fromCharCode is an array.</p>
<p>What do you think?</p>
<p>E</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ten Eyck - Process String</title>
		<link>http://readystate4.com/2008/10/27/stringtocharcode/comment-page-1/#comment-907</link>
		<dc:creator>Ten Eyck - Process String</dc:creator>
		<pubDate>Tue, 28 Oct 2008 04:54:47 +0000</pubDate>
		<guid isPermaLink="false">http://readystate4.com/2008/10/27/stringtocharcode/#comment-907</guid>
		<description>[...] My good friend Mauvis was writing on his blog about to convert a string to comma separated ascii numbers. I commented there about his code. Here&#8217;s how I wrote, and also see his original: String.toCharCode(). [...]</description>
		<content:encoded><![CDATA[<p>[...] My good friend Mauvis was writing on his blog about to convert a string to comma separated ascii numbers. I commented there about his code. Here&#8217;s how I wrote, and also see his original: String.toCharCode(). [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mauvis</title>
		<link>http://readystate4.com/2008/10/27/stringtocharcode/comment-page-1/#comment-906</link>
		<dc:creator>Mauvis</dc:creator>
		<pubDate>Mon, 27 Oct 2008 22:35:05 +0000</pubDate>
		<guid isPermaLink="false">http://readystate4.com/2008/10/27/stringtocharcode/#comment-906</guid>
		<description>I profiled it in Firebug and it is indeed 30% faster. :]</description>
		<content:encoded><![CDATA[<p>I profiled it in Firebug and it is indeed 30% faster. :]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tksh</title>
		<link>http://readystate4.com/2008/10/27/stringtocharcode/comment-page-1/#comment-905</link>
		<dc:creator>tksh</dc:creator>
		<pubDate>Mon, 27 Oct 2008 22:16:28 +0000</pubDate>
		<guid isPermaLink="false">http://readystate4.com/2008/10/27/stringtocharcode/#comment-905</guid>
		<description>String concatenation is (usually) very heavy in any loop, so as a general rule, you shouldn&#039;t do that. It&#039;s because String is basically immutable, although Firefox and Safari&#039;s implementation of String is very efficient.</description>
		<content:encoded><![CDATA[<p>String concatenation is (usually) very heavy in any loop, so as a general rule, you shouldn&#8217;t do that. It&#8217;s because String is basically immutable, although Firefox and Safari&#8217;s implementation of String is very efficient.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mauvis</title>
		<link>http://readystate4.com/2008/10/27/stringtocharcode/comment-page-1/#comment-904</link>
		<dc:creator>Mauvis</dc:creator>
		<pubDate>Mon, 27 Oct 2008 19:10:44 +0000</pubDate>
		<guid isPermaLink="false">http://readystate4.com/2008/10/27/stringtocharcode/#comment-904</guid>
		<description>Takashi king of efficiency!

I like your changes and will add your version beneath mine. I completely agree about not using &lt;code&gt;for in&lt;/code&gt;. This was quick and dirty and admitting I wasn&#039;t thinking (also I generally steer clear of adding prototypes to native objects - I only run this in Firebug when I need it.)

I also like your use of &lt;code&gt;join&lt;/code&gt; instead of all the string logic. 

Thanks!</description>
		<content:encoded><![CDATA[<p>Takashi king of efficiency!</p>
<p>I like your changes and will add your version beneath mine. I completely agree about not using <code>for in</code>. This was quick and dirty and admitting I wasn&#8217;t thinking (also I generally steer clear of adding prototypes to native objects &#8211; I only run this in Firebug when I need it.)</p>
<p>I also like your use of <code>join</code> instead of all the string logic. </p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tksh</title>
		<link>http://readystate4.com/2008/10/27/stringtocharcode/comment-page-1/#comment-903</link>
		<dc:creator>tksh</dc:creator>
		<pubDate>Mon, 27 Oct 2008 17:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://readystate4.com/2008/10/27/stringtocharcode/#comment-903</guid>
		<description>I suppose there must be the reason to do this way, but the code you wrote would not work when you add other prototype method to String.  For example, do like this:

String.prototype.something = &#039;foobar&#039;;
&#039;bob&#039;.toCharCode(); // returns &quot;98,111,98,102&quot;

It&#039;s because you use for...in iteration to run a loop for array.  for...in iteration should be very careful.  For the future version of JavaScript may be able to access &quot;DontEnum&quot; property, or using hasOwnProperty()  .  But in this case, it&#039;s easier to do as follows.

String.prototype.toCharCode = function(){
  var str  = this.split(&#039;&#039;);
  var len  = str.length;
  var work = new Array(len);
  for (var i = 0; i &lt; len; ++i)
  {
    work[i] = str[i];
  }
  return work.join(&#039;,&#039;);
}</description>
		<content:encoded><![CDATA[<p>I suppose there must be the reason to do this way, but the code you wrote would not work when you add other prototype method to String.  For example, do like this:</p>
<p>String.prototype.something = &#8216;foobar&#8217;;<br />
&#8216;bob&#8217;.toCharCode(); // returns &#8220;98,111,98,102&#8243;</p>
<p>It&#8217;s because you use for&#8230;in iteration to run a loop for array.  for&#8230;in iteration should be very careful.  For the future version of JavaScript may be able to access &#8220;DontEnum&#8221; property, or using hasOwnProperty()  .  But in this case, it&#8217;s easier to do as follows.</p>
<p>String.prototype.toCharCode = function(){<br />
  var str  = this.split(&#8221;);<br />
  var len  = str.length;<br />
  var work = new Array(len);<br />
  for (var i = 0; i &lt; len; ++i)<br />
  {<br />
    work[i] = str[i];<br />
  }<br />
  return work.join(&#8216;,&#8217;);<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
