<?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>Vdiscussion &#187; ASCII</title>
	<atom:link href="http://vdiscussion.com/tag/ascii/feed/" rel="self" type="application/rss+xml" />
	<link>http://vdiscussion.com</link>
	<description>Vinoth Kumar&#039;s Discussion</description>
	<lastBuildDate>Wed, 09 Dec 2009 15:34:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>How to Store Binary Data in Strings using PHP</title>
		<link>http://vdiscussion.com/how-to-store-binary-data-in-strings-using-php/</link>
		<comments>http://vdiscussion.com/how-to-store-binary-data-in-strings-using-php/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 16:34:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Programs]]></category>
		<category><![CDATA[Theory Subjects]]></category>
		<category><![CDATA[ASCII]]></category>
		<category><![CDATA[pack( )]]></category>
		<category><![CDATA[Store Binary Data in Strings]]></category>
		<category><![CDATA[unpack( )]]></category>

		<guid isPermaLink="false">http://vdiscussion.com/?p=136</guid>
		<description><![CDATA[How to Store Binary Data in Strings using PHP]]></description>
			<content:encoded><![CDATA[<p>You want to  parse a string that contains values encoded as a binary structure or encode  values into a string. For example, you want to store numbers in their binary  representation instead of as sequences of ASCII characters.</p>
<h4 id="title-IDAYIYPI">1.16.2. Solution</h4>
<p>Use <em>pack( )</em> to store binary data  in a string:</p>
<pre>&lt;?php
$packed = pack('S4',1974,106,28225,32725);
?&gt;</pre>
<p>Use <em>unpack( )</em><a name="ch01_unpackbin"></a> to extract  binary data from a string:</p>
<pre>&lt;?php
$nums = unpack('S4',$packed);
?&gt;</pre>
<p>1.16.3. Discussion</p>
<p>The first argument to <em>pack( )</em> is a format string that  describes how to encode the data that&#8217;s passed in the rest of the arguments. The  format string <tt>S4</tt> tells <em>pack( )</em> to produce four unsigned short  16-bit numbers in machine byte order from its input data. Given 1974, 106,  28225, and 32725 as input on a little-endian machine, this returns eight bytes:  182, 7, 106, 0, 65, 110, 213, and 127. Each two-byte pair corresponds to one of  the input numbers: 7 * 256 + 182 is 1974; 0 * 256 + 106 is 106; 110 * 256 + 65 =  28225; 127 * 256 + 213 = 32725.</p>
<p>The first argument to <em>unpack( )</em> is also a format string,  and the second argument is the data to decode. Passing a format string of  <tt>S4</tt>, the eight-byte sequence that <em>pack( )</em> produced returns a  four-element array of the original numbers. <tt>print_r($nums)</tt> prints:</p>
<pre>Array
(
    [1] =&gt; 1974
    [2] =&gt; 106
    [3] =&gt; 28225
    [4] =&gt; 32725
)</pre>
<p>In <em>unpack( )</em>, format characters and their count can be  followed by a string to be used as an array key. For example:</p>
<pre>&lt;?php
$nums = unpack('S4num',$packed);
print_r($nums);
?&gt;</pre>
<p>This prints:</p>
<pre>Array
(
    [num1] =&gt; 1974
    [num2] =&gt; 106
    [num3] =&gt; 28225
    [num4] =&gt; 32725
)</pre>
<p>Multiple format characters must be separated with <tt>/</tt> in  <em>unpack( )</em>:</p>
<pre>&lt;?php
$nums = unpack('S1a/S1b/S1c/S1d',$packed);
print_r($nums);
?&gt;</pre>
<p>This prints:</p>
<pre>Array
(
    [a] =&gt; 1974
    [b] =&gt; 106
    [c] =&gt; 28225
    [d] =&gt; 32725
)</pre>
]]></content:encoded>
			<wfw:commentRss>http://vdiscussion.com/how-to-store-binary-data-in-strings-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is Dead-Character Messages in Visual Programming</title>
		<link>http://vdiscussion.com/what-is-dead-character-messages-in-visual-programming/</link>
		<comments>http://vdiscussion.com/what-is-dead-character-messages-in-visual-programming/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 14:21:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Theory Subjects]]></category>
		<category><![CDATA[Visual Programming]]></category>
		<category><![CDATA[ANSI]]></category>
		<category><![CDATA[ASCII]]></category>
		<category><![CDATA[Dead-Character Messages]]></category>
		<category><![CDATA[WM_CHAR]]></category>
		<category><![CDATA[WM_DEADCHAR]]></category>
		<category><![CDATA[WM_SYSDEADCHAR]]></category>
		<category><![CDATA[wParam]]></category>

		<guid isPermaLink="false">http://vdiscussion.com/?p=59</guid>
		<description><![CDATA[Windows programs can usually ignore WM_DEADCHAR and WM_SYSDEADCHAR messages, but you should definitely know what dead characters are and how they work. On some non-U.S. English keyboards, certain keys are defined to add a diacritic to a letter. These are called &#8220;dead keys&#8221; because they don&#8217;t generate characters by themselves. For instance, when a German [...]]]></description>
			<content:encoded><![CDATA[<p>Windows programs can usually ignore <strong>WM_DEADCHAR</strong> and <strong>WM_SYSDEADCHAR</strong> messages,  but you should definitely know what dead characters are and how they work.</p>
<p>On some non-U.S. English keyboards, certain keys are defined to add a  diacritic to a letter. These are called &#8220;dead keys&#8221; because they don&#8217;t generate  characters by themselves. For instance, when a German keyboard is installed, the  key that is in the same position as the +/= key on a U.S. keyboard is a dead key  for the grave accent (`) when shifted and the acute accent (´) when unshifted.</p>
<p>When a user presses this dead key, your window procedure receives a  <strong>WM_DEADCHAR</strong> message with <strong><em>wParam</em></strong> equal to ASCII or Unicode code for the  diacritic by itself. When the user then presses a letter key that can be written  with this diacritic (for instance, the A key), the window procedure receives a  <strong>WM_CHAR</strong> message where <em>wParam</em> is the ANSI code for the letter `a&#8217; with the  diacritic.</p>
<p>Thus, your program does not have to process the <strong>WM_DEADCHAR</strong> message because  the <strong>WM_CHAR</strong> message gives the program all the information it needs. The Windows  logic even has built-in error handling: If the dead key is followed by a letter  that can&#8217;t take a diacritic (such as `s&#8217;), the window procedure receives two <strong> WM_CHAR</strong> messages in a row—the first with <em>wParam</em> equal to the <strong>ASCII</strong> code  for the diacritic by itself (the same <em>wParam</em> value delivered with the  WM_DEADCHAR message) and the second with <em>wParam</em> equal to the <strong>ASCII</strong> code  for the letter `s&#8217;.</p>
<p>Of course, the best way to get a feel for this is to see it in action. You  need to load a foreign keyboard that uses dead keys, such as the German keyboard  that I described earlier. You do this in the Control Panel by selecting Keyboard  and then the Language tab. Then you need an application that shows you the  details of every keyboard message a program can receive.</p>
]]></content:encoded>
			<wfw:commentRss>http://vdiscussion.com/what-is-dead-character-messages-in-visual-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
