<?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: SimpleCode</title>
	<atom:link href="http://simplebits.com/notebook/2004/02/05/simplecode/feed/" rel="self" type="application/rss+xml" />
	<link>http://simplebits.com/notebook/2004/02/05/simplecode/</link>
	<description>Handcrafted pixels &#38; text from Salem, Massachusetts.</description>
	<lastBuildDate>Tue, 08 Dec 2009 23:15:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<item>
		<title>By: Anonymous</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2170</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 14 Jul 2004 18:00:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2170</guid>
		<description>If you copy the output back to the input you&#039;ll notice it doesn&#039;t support the escaped characters, but I guess we shouln&#039;t be using nbsp&#039;s anyway :)
</description>
		<content:encoded><![CDATA[<p>If you copy the output back to the input you&#8217;ll notice it doesn&#8217;t support the escaped characters, but I guess we shouln&#8217;t be using nbsp&#8217;s anyway :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Smith</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2169</link>
		<dc:creator>Steve Smith</dc:creator>
		<pubDate>Sun, 14 Mar 2004 16:42:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2169</guid>
		<description>With PHP, you could create a simple function to output formatted code:
&lt;code&gt;function prep_code($string) {&lt;br /&gt;	&#160;&#160;$string = htmlspecialchars($string);&lt;br /&gt;	&#160;&#160;$string = str_replace(&quot;\t&quot;, &#039;&#160;&#160;&#039;, $string);&lt;br /&gt;	&#160;&#160;$string = str_replace(&#039;&#160;&#160;&#039;, &#039;&#160;&#160;&#039;, $string);&lt;br /&gt;	&#160;&#160;$string = nl2br($string);&lt;br /&gt;	&#160;&#160;return $string;&lt;br /&gt;}
&lt;/code&gt;
Then just call the function:
&lt;code&gt;echo prep_code($code_string);&lt;/code&gt;
This includes double-spaces, tabs, etc.
</description>
		<content:encoded><![CDATA[<p>With PHP, you could create a simple function to output formatted code:<br />
<code>function prep_code($string) {<br />	&nbsp;&nbsp;$string = htmlspecialchars($string);<br />	&nbsp;&nbsp;$string = str_replace("\t", '&#160;&#160;', $string);<br />	&nbsp;&nbsp;$string = str_replace('&#160;&#160;', '&nbsp;&nbsp;', $string);<br />	&nbsp;&nbsp;$string = nl2br($string);<br />	&nbsp;&nbsp;return $string;<br />}<br />
</code><br />
Then just call the function:<br />
<code>echo prep_code($code_string);</code><br />
This includes double-spaces, tabs, etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maxwel Leite</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2168</link>
		<dc:creator>Maxwel Leite</dc:creator>
		<pubDate>Sat, 28 Feb 2004 09:07:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2168</guid>
		<description>Forget replace the tab or &quot;\t&quot;(in JS) in yours JS version (http://wootest.net/simplecode.htm)?
</description>
		<content:encoded><![CDATA[<p>Forget replace the tab or &#8220;\t&#8221;(in JS) in yours JS version (<a href="http://wootest.net/simplecode.htm" rel="nofollow">http://wootest.net/simplecode.htm</a>)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Synistar</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2167</link>
		<dc:creator>Synistar</dc:creator>
		<pubDate>Tue, 10 Feb 2004 16:50:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2167</guid>
		<description>&lt;p&gt;
There is already a &lt;a href=&quot;http://search.cpan.org/&quot; rel=&quot;nofollow&quot;&gt;CPAN&lt;/a&gt; &lt;a href=&quot;http://search.cpan.org/~gaas/HTML-Parser-3.35/lib/HTML/Entities.pm&quot; rel=&quot;nofollow&quot;&gt;module&lt;/a&gt; for this. Try something like:
&lt;/p&gt;&lt;code&gt;
use HTML::Entities ();
$encoded = HTML::Entities::encode($a);
$encoded = HTML::Entities::encode_numeric($a);
$decoded = HTML::Entities::decode($a);
&lt;/code&gt;
&lt;p&gt;
Or you can use the built in escapeHTML() function in CGI.pm that ships with all modern versions of perl.&lt;/p&gt;
&lt;code&gt;
use CGI;
my $q=CGI-&gt;new();
print $q-&gt;header(),
$q-&gt;start_html();
print $q-&gt;h1($header),
$q-&gt;escapeHTML($string_that_i_want_to_escape);
&lt;/code&gt;
&lt;p&gt;Re-inventing the wheel can be fun. But the perl community has lots of wheel-makers. :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>
There is already a <a href="http://search.cpan.org/" rel="nofollow">CPAN</a> <a href="http://search.cpan.org/~gaas/HTML-Parser-3.35/lib/HTML/Entities.pm" rel="nofollow">module</a> for this. Try something like:
</p>
<p><code><br />
use HTML::Entities ();<br />
$encoded = HTML::Entities::encode($a);<br />
$encoded = HTML::Entities::encode_numeric($a);<br />
$decoded = HTML::Entities::decode($a);<br />
</code></p>
<p>
Or you can use the built in escapeHTML() function in CGI.pm that ships with all modern versions of perl.</p>
<p><code><br />
use CGI;<br />
my $q=CGI->new();<br />
print $q->header(),<br />
$q->start_html();<br />
print $q->h1($header),<br />
$q->escapeHTML($string_that_i_want_to_escape);<br />
</code></p>
<p>Re-inventing the wheel can be fun. But the perl community has lots of wheel-makers. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: daniel</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2166</link>
		<dc:creator>daniel</dc:creator>
		<pubDate>Mon, 09 Feb 2004 22:40:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2166</guid>
		<description>Great tool, I&#039;ve already been reading your site, and decided to comment. It works great, I&#039;ve already used it a couple times. Thanks!
</description>
		<content:encoded><![CDATA[<p>Great tool, I&#8217;ve already been reading your site, and decided to comment. It works great, I&#8217;ve already used it a couple times. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesper</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2165</link>
		<dc:creator>Jesper</dc:creator>
		<pubDate>Mon, 09 Feb 2004 17:51:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2165</guid>
		<description>Terry: purely &#039;semantics&#039;. You CAN use &lt;code&gt;&lt;b&gt;&lt;big&gt;&lt;big&gt;&lt;big&gt;dfhgfd&lt;/big&gt;&lt;/big&gt;&lt;/big&gt;&lt;/b&gt;&lt;/code&gt; instead of h1 too, but it&#039;s much harder to style with CSS and you don&#039;t instantly recognize what it does. With your method you have to actively investigate whether a &lt;code&gt;&lt;textarea&gt;&lt;/code&gt; is a code sample or a form element and/or attach clumsy &lt;code&gt;id&lt;/code&gt;s or &lt;code&gt;class&lt;/code&gt;es if you want to style it differently than an actual form textarea.
</description>
		<content:encoded><![CDATA[<p>Terry: purely &#8216;semantics&#8217;. You CAN use <code>&lt;b&gt;&lt;big&gt;&lt;big&gt;&lt;big&gt;dfhgfd&lt;/big&gt;&lt;/big&gt;&lt;/big&gt;&lt;/b&gt;</code> instead of h1 too, but it&#8217;s much harder to style with CSS and you don&#8217;t instantly recognize what it does. With your method you have to actively investigate whether a <code>&lt;textarea&gt;</code> is a code sample or a form element and/or attach clumsy <code>id</code>s or <code>class</code>es if you want to style it differently than an actual form textarea.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Terry</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2164</link>
		<dc:creator>Terry</dc:creator>
		<pubDate>Sun, 08 Feb 2004 22:05:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2164</guid>
		<description>Hi,
Nice script. I came across this a while back:
http://centricle.com/tools/html-entities/
What I&#039;m wondering, though, is what are the benefits of doing it this as opposed to using a styled textarea?
readonly=&quot;readonly&quot; cols=&quot;80%&quot; rows=&quot;100%&quot;
style=&quot;border: 1px solid black; overflow: visible; padding: 10px;&quot;
Am I missing something? I know using a textarea has extra code required from the form tags itself whereas dumping html entities into a code tags requires less markup. But besides that what are the benefits?
Thanks.
</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Nice script. I came across this a while back:<br />
<a href="http://centricle.com/tools/html-entities/" rel="nofollow">http://centricle.com/tools/html-entities/</a><br />
What I&#8217;m wondering, though, is what are the benefits of doing it this as opposed to using a styled textarea?<br />
readonly=&#8221;readonly&#8221; cols=&#8221;80%&#8221; rows=&#8221;100%&#8221;<br />
style=&#8221;border: 1px solid black; overflow: visible; padding: 10px;&#8221;<br />
Am I missing something? I know using a textarea has extra code required from the form tags itself whereas dumping html entities into a code tags requires less markup. But besides that what are the benefits?<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stombi</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2163</link>
		<dc:creator>stombi</dc:creator>
		<pubDate>Sun, 08 Feb 2004 21:08:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2163</guid>
		<description>sorry Jesper, I was tired and it appears to me that it was easier to post here than at your site.
Thanks for the modification.
</description>
		<content:encoded><![CDATA[<p>sorry Jesper, I was tired and it appears to me that it was easier to post here than at your site.<br />
Thanks for the modification.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesper</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2162</link>
		<dc:creator>Jesper</dc:creator>
		<pubDate>Sun, 08 Feb 2004 18:25:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2162</guid>
		<description>The script should now replace CR, LF or CRLF.
</description>
		<content:encoded><![CDATA[<p>The script should now replace CR, LF or CRLF.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesper</title>
		<link>http://simplebits.com/notebook/2004/02/05/simplecode/#comment-2161</link>
		<dc:creator>Jesper</dc:creator>
		<pubDate>Sun, 08 Feb 2004 04:08:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.simplebits.com/wp/notebook/2004/02/05/simplecode/#comment-2161</guid>
		<description>stombi: To my understanding, textarea&#039;s have ALWAYS used CRLF across all platforms and browsers. And I was using Dan&#039;s regexes. Maybe the CGI module replaces all LFs with CRs. I don&#039;t know, I never &lt;code&gt;use CGI;&lt;/code&gt;. If you&#039;d like to report some of your findings, I&#039;d be more than happy to change the script accordingly. jesper AT lindholms DOT com.
</description>
		<content:encoded><![CDATA[<p>stombi: To my understanding, textarea&#8217;s have ALWAYS used CRLF across all platforms and browsers. And I was using Dan&#8217;s regexes. Maybe the CGI module replaces all LFs with CRs. I don&#8217;t know, I never <code>use CGI;</code>. If you&#8217;d like to report some of your findings, I&#8217;d be more than happy to change the script accordingly. jesper AT lindholms DOT com.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

