<?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"
	>
<channel>
	<title>Comments on: Octal, Hexadecimal, And Decimal Conversion</title>
	<atom:link href="http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/</link>
	<description>Bay View Consulting Services, Inc.</description>
	<pubDate>Thu, 28 Aug 2008 18:16:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: William Ward</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-41732</link>
		<dc:creator>William Ward</dc:creator>
		<pubDate>Tue, 08 Jul 2008 19:47:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-41732</guid>
		<description>I think (s)printf is probably a lot more readable than using pack and unpack, though I suspect yours may be faster.</description>
		<content:encoded><![CDATA[<p>I think (s)printf is probably a lot more readable than using pack and unpack, though I suspect yours may be faster.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: makjander</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-41729</link>
		<dc:creator>makjander</dc:creator>
		<pubDate>Tue, 08 Jul 2008 17:42:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-41729</guid>
		<description>oops... hehe... i've run it now and see what you say it outputs, i've didn't tested before
but you can change it using a workaround:

$number=5;
print unpack "B8", (pack "J", $number);</description>
		<content:encoded><![CDATA[<p>oops&#8230; hehe&#8230; i&#8217;ve run it now and see what you say it outputs, i&#8217;ve didn&#8217;t tested before<br />
but you can change it using a workaround:</p>
<p>$number=5;<br />
print unpack &#8220;B8&#8243;, (pack &#8220;J&#8221;, $number);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Ward</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-41724</link>
		<dc:creator>William Ward</dc:creator>
		<pubDate>Tue, 08 Jul 2008 16:28:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-41724</guid>
		<description>That doesn't work the way you say.  Did you run it?

When I run your program I get "00110101" instead.  Pack and unpack work on character strings, so 5 is really the string "5" and 00110101 is the ASCII code for the "5" character.</description>
		<content:encoded><![CDATA[<p>That doesn&#8217;t work the way you say.  Did you run it?</p>
<p>When I run your program I get &#8220;00110101&#8243; instead.  Pack and unpack work on character strings, so 5 is really the string &#8220;5&#8243; and 00110101 is the ASCII code for the &#8220;5&#8243; character.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: makjander</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-41706</link>
		<dc:creator>makjander</dc:creator>
		<pubDate>Tue, 08 Jul 2008 07:45:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-41706</guid>
		<description>to convert a decimal number into binary it's just even more easy: use UNPACK!!

for example:

$number=5;
print unpack "B8", $number;   

will output:
00000101</description>
		<content:encoded><![CDATA[<p>to convert a decimal number into binary it&#8217;s just even more easy: use UNPACK!!</p>
<p>for example:</p>
<p>$number=5;<br />
print unpack &#8220;B8&#8243;, $number;   </p>
<p>will output:<br />
00000101</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saurabh</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-34179</link>
		<dc:creator>saurabh</dc:creator>
		<pubDate>Mon, 14 Apr 2008 16:41:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-34179</guid>
		<description>Oh sorry, never mind. oct converts from octal, i thought it was the string representation in octal of its arg.</description>
		<content:encoded><![CDATA[<p>Oh sorry, never mind. oct converts from octal, i thought it was the string representation in octal of its arg.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saurabh</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-34178</link>
		<dc:creator>saurabh</dc:creator>
		<pubDate>Mon, 14 Apr 2008 16:39:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-34178</guid>
		<description>&#62; But there’s no bin() function in Perl. You have to use oct() with a "0b" prefix:
&#62; $num = oct("0b" . $bin);

And how exactly does that replace "bin()" (you know it's converting binary to octal right)?</description>
		<content:encoded><![CDATA[<p>&gt; But there’s no bin() function in Perl. You have to use oct() with a &#8220;0b&#8221; prefix:<br />
&gt; $num = oct(&#8221;0b&#8221; . $bin);</p>
<p>And how exactly does that replace &#8220;bin()&#8221; (you know it&#8217;s converting binary to octal right)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bharat</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-24257</link>
		<dc:creator>bharat</dc:creator>
		<pubDate>Thu, 27 Dec 2007 00:02:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-24257</guid>
		<description>Thanks a lot to William Ward &#38; Umut Topkara
This conversion had helped me a lot...</description>
		<content:encoded><![CDATA[<p>Thanks a lot to William Ward &amp; Umut Topkara<br />
This conversion had helped me a lot&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Praneel</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-1311</link>
		<dc:creator>Praneel</dc:creator>
		<pubDate>Tue, 03 Oct 2006 02:15:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-1311</guid>
		<description>Nice piece of work. Exactly what I wanted.</description>
		<content:encoded><![CDATA[<p>Nice piece of work. Exactly what I wanted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Ward</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-6</link>
		<dc:creator>William Ward</dc:creator>
		<pubDate>Mon, 30 Jan 2006 06:26:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-6</guid>
		<description>Yes, I mentioned that above (the "%04o" example) but you explained it better.  Thanks!</description>
		<content:encoded><![CDATA[<p>Yes, I mentioned that above (the &#8220;%04o&#8221; example) but you explained it better.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Umut Topkara</title>
		<link>http://www.bayview.com/blog/2002/08/15/octal-hexadecimal-and-decimal-conversion/#comment-5</link>
		<dc:creator>Umut Topkara</dc:creator>
		<pubDate>Mon, 30 Jan 2006 02:39:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.bayview.com/blog/?p=14#comment-5</guid>
		<description>Hello,

Thank you for the helpful page. I'd like to contribute my 0.2 cents.

Sometimes you to format with leading 0s, e.g. when encoding URLs, 
you need x0A rather than xA. For those cases you can use "%0numberx"
instead of "%0x" as the format string, and the sprintf will fill in
the necessary number of zeroes to make sure that the resulting string
is the specified number of characters.

Here's how we could use this to encode strings for URLs:
perl -pe 's/([^a-zA-z])/"\%" . sprintf("%02x",ord($1))/eg'

You could use it to send files as thunderbird emails from command line:

cat email.txt &#124; perl -pe 's/([^a-zA-z])/"\%" . sprintf("%02x",ord($1))/eg' &#124; xargs -iX thunderbird -compose 'mailto:somebody@nowhere.net?subject=PerlHack&#38;body=X'

Hope this would be helpful to someone.

-umut</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Thank you for the helpful page. I&#8217;d like to contribute my 0.2 cents.</p>
<p>Sometimes you to format with leading 0s, e.g. when encoding URLs,<br />
you need x0A rather than xA. For those cases you can use &#8220;%0numberx&#8221;<br />
instead of &#8220;%0x&#8221; as the format string, and the sprintf will fill in<br />
the necessary number of zeroes to make sure that the resulting string<br />
is the specified number of characters.</p>
<p>Here&#8217;s how we could use this to encode strings for URLs:<br />
perl -pe &#8217;s/([^a-zA-z])/&#8221;\%&#8221; . sprintf(&#8221;%02x&#8221;,ord($1))/eg&#8217;</p>
<p>You could use it to send files as thunderbird emails from command line:</p>
<p>cat email.txt | perl -pe &#8217;s/([^a-zA-z])/&#8221;\%&#8221; . sprintf(&#8221;%02x&#8221;,ord($1))/eg&#8217; | xargs -iX thunderbird -compose &#8216;mailto:somebody@nowhere.net?subject=PerlHack&amp;body=X&#8217;</p>
<p>Hope this would be helpful to someone.</p>
<p>-umut</p>
]]></content:encoded>
	</item>
</channel>
</rss>
