<?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>zehnet.de</title>
	<atom:link href="http://www.zehnet.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zehnet.de</link>
	<description>programming talk and more</description>
	<lastBuildDate>Tue, 11 Aug 2009 22:23:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Wordpress PHP Execution Plugin</title>
		<link>http://www.zehnet.de/2009/02/25/wordpress-php-execution-plugin/</link>
		<comments>http://www.zehnet.de/2009/02/25/wordpress-php-execution-plugin/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 19:50:06 +0000</pubDate>
		<dc:creator>nik</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[eval]]></category>
		<category><![CDATA[execution]]></category>
		<category><![CDATA[PHP Execution Plugin]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.zehnet.de/2009/02/25/wordpress-php-execution-plugin/</guid>
		<description><![CDATA[The PHP Execution Plugin is a Wordpress plugin which allows users to write php code inside of their posts and pages. Embedded php code will be executed when the post is shown. In doing so, the plugin offers the possibility to utilize dynamic content inside of posts.
Probably you might say, that there are already plugins [...]]]></description>
			<content:encoded><![CDATA[<p><img title="php content" src="http://www.zehnet.de/_blog/assets/php_execution/screenshot-00.jpg" alt="" /></p>
<p>The PHP Execution Plugin is a <a title="wordpress" href="http://wordpress.org/">Wordpress</a> plugin which allows users to write <a title="wordpress" href="http://www.php.net/">php</a> code inside of their posts and pages. Embedded php code will be executed when the post is shown. In doing so, the plugin offers the possibility to utilize dynamic content inside of posts.</p>
<p>Probably you might say, that there are already plugins that do the same!<br />
So why another plugin that executes php code?</p>
<p>Well this plugin integrates well with Wordpress&#8217; visual editor as the picture above shows. So in contrast to other plugins, you <strong>don&#8217;t need to turn off the visual editor</strong> in order to edit your php code.</p>
<p><span id="more-244"></span></p>
<h2>Demonstration</h2>
<p>With this plugin installed, you can insert php code into your post in html view and switch to visual view without losing or destroying the code:</p>
<p><a href="http://www.zehnet.de/_blog/assets/php_execution/screenshot-01.jpg"><img title="html view" src="http://www.zehnet.de/_blog/assets/php_execution/screenshot-01.jpg" alt="" /></a></p>
<p>This is how the php code above looks in the visual editor:</p>
<p><a href="http://www.zehnet.de/_blog/assets/php_execution/screenshot-02.jpg"><img title="wysiwyg view" src="http://www.zehnet.de/_blog/assets/php_execution/screenshot-02.jpg" alt="" /></a></p>
<p>You can even drag and drop your code snippets around:</p>
<p><a href="http://www.zehnet.de/_blog/assets/php_execution/screenshot-03.jpg"><img title="drag drop code" src="http://www.zehnet.de/_blog/assets/php_execution/screenshot-03.jpg" alt="" /></a></p>
<p>The executed php code inside the post will look like this:</p>
<p><a href="http://www.zehnet.de/_blog/assets/php_execution/screenshot-04.jpg"><img title="executed code" src="http://www.zehnet.de/_blog/assets/php_execution/screenshot-04.jpg" alt="" /></a></p>
<h2>Installation</h2>
<p>This plugin is installed like any other Wordpress plugin:</p>
<ul>
<li>Download the latest version of the plugin.</li>
<li>Unzip it into the <code>/wp-content/plugins/</code> folder of your Wordpress installation resulting in a <code>/wp-content/plugins/php_execution/</code> folder.</li>
<li>Login as administrator and activate the plugin.</li>
<li>Wordpress&#8217; tag balancing has to be turned <strong>off</strong>. This is true by default. If you have enabled tag balancing, turn it off again by unchecking &#8220;<em>WordPress should correct invalidly nested XHTML automatically</em>&#8221; in Settings»Writing of the admin section.</li>
<li>Optionally set PHP execution permissions in the Settings»PHP Execution panel. By default all administrators possess the permission to execute php code.</li>
<li><strong>As javascript code is added to the editor, you have to clear your browser cache !!! </strong>Otherwise the plugin won&#8217;t work as the code added by it simply won&#8217;t get executed. For information on how to clear the browser cache, follow this <a title="How do I clear my web browser's cache?" href="http://kb.iu.edu/data/ahic.html">link</a>.</li>
</ul>
<p>For information on how to install Wordpress plugins in general follow this <a href="http://codex.wordpress.org/Managing_Plugins#Installing_Plugins">link</a>.</p>
<h3>Requirements</h3>
<ul>
<li>WordPress 2.5 or higher</li>
<li>PHP Execution is compatible with <strong>WordPress MU</strong>, as long as you install it in conjunction with another plugin called <em>Unfiltered MU </em>(<a href="http://wordpress.org/extend/plugins/unfiltered-mu/">http://wordpress.org/extend/plugins/unfiltered-mu/</a>). See the comments below written by <em>Ray</em> for further information.</li>
</ul>
<p><strong><em>tested on WordPress 2.5, 2.6, 2.7 &amp; 2.8 with IE 6 &amp; 7, Firefox 3</em></strong></p>
<h2>Usage</h2>
<h3>Editing PHP</h3>
<ul>
<li>php code can be edited in the html view of the editor.</li>
<li>php code is embedded into a post in the same way as in any other html page: a php block begins with <code>&lt;?php</code> and ends with <code>?&gt;</code>. The <a href="http://www.php.net/ini.core">short open tag</a>, i.e. <code>&lt;?</code>, is <strong>not</strong> supported.</li>
<li>One <strong>restriction</strong> is, that you are not allowed to use the ending delimeter (<code>?&gt;</code>) somewhere inside a string in your php code block. If you do so, this ending delimeter will be matched and your code will inevitably break apart. So don&#8217;t write e.g.:
<pre>some text
&lt;?php $test = "hello <strong>?&gt;</strong>"  ?&gt;
more text</pre>
<p>Writing <code>$test = "hello ?&amp;gt;"</code> instead will not lead to any problems.</li>
<li>Php code is not executed in the <a href="http://www.php.net/manual/en/language.variables.scope.php">global scope</a>. If you need to gain access to variables in the global scope you need to &#8220;import&#8221; them first with <code>global $var1, $var2;</code>.</li>
<li>This plugin does not evaluate every single code snippet, but the content of the post as a whole. So the following lines won&#8217;t result in errors:
<pre>&lt;?php if ($test==true) { ?&gt;
The test was successful.
&lt;?php } else { ?&gt;
The test failed.
&lt;?php } ?&gt;</pre>
</li>
<li>When switching between html and visual view the php code is not altered in any case. All html tags, whitespaces etc. in your code are preserved.</li>
</ul>
<h3>Admin Section: setting permissions for code execution</h3>
<p>As executing php code is a sensitive task and possible exploitation should be prevented for security reasons, the PHP Execution Plugin provides an administration panel (Settings»PHP Execution) where you can grant or deny php execution permissions to certain <a href="http://codex.wordpress.org/Roles_and_Capabilities">Wordpress roles</a> in general or set explicit permissions for specific users.</p>
<p>The plugin also automatically prevents users with no php execution rights from editing posts or pages of users with these rights. It thus fixes a possible security leak where people without php execution rights can still execute code with editing other users&#8217; posts.</p>
<p><a href="http://www.zehnet.de/_blog/assets/php_execution/screenshot-admin.jpg"><img title="admin section" src="http://www.zehnet.de/_blog/assets/php_execution/screenshot-admin-thumb.jpg" alt="" width="250" /></a></p>
<h2>ToDos</h2>
<ul>
<li>Internationalization</li>
</ul>
<h2>License</h2>
<p>
<a href="http://creativecommons.org/licenses/GPL/2.0/" class="license"><img src="http://creativecommons.org/images/public/cc-GPL-a.png" alt="CC-GNU GPL"><br>
<small>Creative Commons GNU GPL 2.0</small></a></p>
<h2>Download</h2>
<p><a class="download" title="download php_execution.zip" href="http://www.zehnet.de/files/phpExecutionPlugin/$zip_php_execution?dl">php_execution.zip</a> (version 1.0.1 &#8211; <em>2009/08/07</em>)<br />
<a class="folder" title="browse archive" href="http://www.zehnet.de/files/phpExecutionPlugin/">browse the contents of php_execution.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zehnet.de/2009/02/25/wordpress-php-execution-plugin/feed/</wfw:commentRss>
		<slash:comments>76</slash:comments>
		</item>
		<item>
		<title>Flex FileUpload Component</title>
		<link>http://www.zehnet.de/2009/02/23/flex-fileupload-component/</link>
		<comments>http://www.zehnet.de/2009/02/23/flex-fileupload-component/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 16:58:19 +0000</pubDate>
		<dc:creator>nik</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[FileReference.load]]></category>
		<category><![CDATA[flash player 10]]></category>
		<category><![CDATA[FlexFileUpload]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://www.zehnet.de/2009/03/18/flex-fileupload-component/</guid>
		<description><![CDATA[What we&#8217;ve got here is a FileUpload component for Flex which utilizes the new FileReference.load method available since Flash Player 10 to support uploading of large files.
As a lot of providers choose a very small size for their PHP ini settings of upload_max_filesize and post_max_size, uploading files bigger than 2mb is often not supported. This [...]]]></description>
			<content:encoded><![CDATA[<p><img title="Flex FileUploader" src="http://www.zehnet.de/_blog/assets/file-uploader/header.jpg" alt="" /></p>
<p>What we&#8217;ve got here is a FileUpload component for Flex which utilizes the new <code><a href="http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html#load()">FileReference.load</a></code> method available since <a href="http://labs.adobe.com/technologies/flashplayer10/">Flash Player 10</a> to support uploading of large files.<br />
As a lot of providers choose a very small size for their PHP ini settings of <code><a href="http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize">upload_max_filesize</a></code> and <code><a href="http://www.php.net/manual/en/ini.core.php#ini.post-max-size">post_max_size</a></code>, uploading files bigger than 2mb is often not supported. This can be very annoying if you like to upload mp3 or video files, which easily can exceed the maximum accepted file size. In this case you normally have to go with an FTP client.</p>
<h3>Uploading large files</h3>
<p>If supported by the client&#8217;s Flash Player this upload component utilizes the new <code>FileReference.load</code> method to load the file into the ram of the client computer at first. Once loaded the file data can be read via the <code>data</code> property of the <code>FileReference</code> object. It is now possible to extract chunks of the loaded file data and upload those chunks to the server separately. This way the upload-data won&#8217;t exceed the maximum accepted post data of the server as the chunks used are a lot smaller. On the server side, a php script is joining the chunks together to the original file.</p>
<h3>Resuming Uploads</h3>
<p>Prior to uploading the uploader also calculates an <a href="http://en.wikipedia.org/wiki/Adler-32">adler32 checksum</a> of the file data. This checksum is used to check if a partially uploaded file already exists on the server and an upload operation can be resumed.</p>
<p><span id="more-264"></span></p>
<h2>Screenshots</h2>
<p>Since i don&#8217;t want unkown people to upload random files to my server, i can only offer some screenshots of the application here. The best thing would be, if you grab the source code which is available at the bottom of this page and test it out yourself.</p>
<p><img title="selected files for upload" src="http://www.zehnet.de/_blog/assets/file-uploader/screenshots-start.jpg" alt="" /><br />
<em>selected files for upload</em></p>
<p><img title="file already exists dialog" src="http://www.zehnet.de/_blog/assets/file-uploader/screenshots-file.exists.jpg" alt="" /><br />
<em>file already exists dialog</em></p>
<p><img title="ramloading file" src="http://www.zehnet.de/_blog/assets/file-uploader/screenshots-ramloading.jpg" alt="" /><br />
<em>loading file into ram to for chunkwise upload</em></p>
<p><img title="calculating checksum" src="http://www.zehnet.de/_blog/assets/file-uploader/screenshots-checksumming.jpg" alt="" /><br />
<em>calculating an adler32 checksum of the file data to support the resume of uploads</em></p>
<p><img title="uploading file" src="http://www.zehnet.de/_blog/assets/file-uploader/screenshots-uploading.jpg" alt="" /><br />
<em>uploading the file in chunks</em></p>
<h2>License</h2>
<p>
<a href="http://creativecommons.org/licenses/LGPL/2.1/" class="license"><img src="http://creativecommons.org/images/public/cc-LGPL-a.png" alt="CC-GNU LGPL"><br>
<small>Creative Commons GNU LGPL 2.1</small></a></p>
<h2>Download</h2>
<p><a class="download" title="FlexFileUploadComponent.zip" href="http://www.zehnet.de/files/FlexFileUploadComponent/$zip_FlexFileUploadComponent?dl">FlexFileUploadComponent.zip</a> (version 0.1.4)<br />
<a class="folder" title="browse archive" href="http://www.zehnet.de/files/FlexFileUploadComponent/">browse the source code and contents of FlexFileUploadComponent.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zehnet.de/2009/02/23/flex-fileupload-component/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>red5 Remote SharedObject experience &amp; tips</title>
		<link>http://www.zehnet.de/2008/04/11/red5-remote-sharedobject-experience-tips/</link>
		<comments>http://www.zehnet.de/2008/04/11/red5-remote-sharedobject-experience-tips/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 22:30:34 +0000</pubDate>
		<dc:creator>nik</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[red5]]></category>
		<category><![CDATA[sharedObject]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://localhost/zehnet.de/?p=14</guid>
		<description><![CDATA[The following post is a copy of a post i originally contributed to the red5 mailing list.
Hello Red5 Community,
i am kind of new to red5 and spend the last days tyring to figure out how to use shared objects with red5.
In the following lines i like to summarise my experiences. This should serve as a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://osflash.org/red5"><img title="red5 project home" src="http://www.zehnet.de/_blog/assets/red5-sharedObject/header.jpg" alt="red5 project hom" /></a></p>
<blockquote><p>The following post is a copy of a post i originally contributed to the red5 mailing list.</p></blockquote>
<p>Hello Red5 Community,</p>
<p>i am kind of new to red5 and spend the last days tyring to figure out how to use shared objects with red5.<br />
In the following lines i like to summarise my experiences. This should serve as a hint for others who come accross the same questions and problems that i did.<br />
Please feel free to correct or supplement the following lines where neccessary.<br />
When discussing SharedObjects in the following, i  refer to Remote Shared Objects and not Local Shared Objects of course. I also focus on non-persistent ones.<br />
<span id="more-26"></span></p>
<h3>What are SharedObjects good for?</h3>
<p>SharedObjects (SOs) are helpful to synchronize data between multiple clients in real-time and to invoke methods on multiple clients at once. A Remote SharedObject is an Object which is shared between multiple clients, namely all clients of the same scope.</p>
<p><strong>So what is a Scope?</strong><br />
You can think of a scope as a chat room which is defined by the <strong>uri</strong> that is used to connect the server:</p>
<pre>rtmp://localhost/red5test/lobby</pre>
<p>red5test is the application scope<br />
lobby is a room scope, a child scope of red5test<br />
for more information on scopes see: <a href="http://jira.red5.org/confluence/display/docs/Scopes+and+Contexts">http://jira.red5.org/confluence/display/docs/Scopes+and+Contexts</a></p>
<h3>How to connect to SOs (clientside)?</h3>
<p>A  Client can connect to a SO using the following Actionscript lines:</p>
<pre>// at first you need to establish a connection to the server of course
nc = new NetConnection();
nc.connect( "rtmp://localhost/red5test/", true );

// when the NetConnection is successfully established
// (you have to listen to NetStatusEvent.NET_STATUS event)
// you can connect to a remote SharedObject e.g. named "chat"
so = SharedObject.getRemote("chat", nc.uri, false);

// when the connection to the SO is successfully established,
// you can begin to specify its contents
so.setProperty("message","hello to all");</pre>
<h3>How does red5 handle SOs?</h3>
<p>If a client connects to a SO, red5 looks into the specified scope if a SO named e.g. &#8220;chat&#8221; already exists.<br />
If it does, red5 uses it, if not, red5 creates a new SO for the Scope and uses that.<br />
When the last client connected to a SO disconnects from it, the SO will be destroyed (at least for non-persistent ones).</p>
<h3>SOs on the serverside</h3>
<p><strong>a) Access SOs on the serverside</strong><br />
SOs can also be accessed from the serverside, i.e. the server also can make changes to the SO and broadcast them to all connected clients.</p>
<p>To check wether a certain SO exists you can use the following lines in your Java Application:</p>
<pre>//get scope of the current connection first
IScope scope = Red5.getConnectionLocal().getScope();
// get SO
ISharedObject so = getSharedObject(scope, "chat");</pre>
<p><strong>b) Create SOs on the serverside</strong><br />
You can also create SOs on the serverside with the following lines:<br />
extracted from <a href="http://www.joachim-bauch.de/tutorials/red5/MigrationGuide.txt#sharedobjects">Joachim Bauchs tutorial</a>:</p>
<p>To create a new shared object when a room is created, you can override the method roomStart in your application:</p>
<pre>public class SampleApplication extends ApplicationAdapter {

  public boolean roomStart(IScope room) {
      if (!super.roomStart(room))
          return false;

      createSharedObject(room, "sampleSO", true);
      ISharedObject so = getSharedObject(room, "sampleSO");

      // Now you could do something with the shared object...

      return true;
  }

}</pre>
<p>If a shared object should be created for connections to the main application,  e.g. rtmp://server/application, the same must be done in the method  appStart.</p>
<h3>So what is it good for to create SOs by yourself when red5 does it for you automatically?</h3>
<p>One advantage  is, that you can attach a Listener to the SO which is notified when a new client connects to the SO, updates data, disconnects etc. (See <a href="http://dl.fancycode.com/red5/api/org/red5/server/api/so/ISharedObjectListener.html">ISharedObjectListener</a>)</p>
<p><strong>Problem: clientside initiated vs. serverside initiated SOs</strong></p>
<p>Creating SOs in your java application code can leed to some unexpected problems (It was at least for me).<br />
The problem is related to something i refer to as clientside vs. serverside initiated SOs.<br />
Of course all SOs wil be created on the red5 server. But there is a difference who initiated the creation.</p>
<ul>
<li> a) a serverside initiated SO is a SO that you have created with createSharedObject in your serverside code. It is then waiting for clients to connect.<br />
When a client connects to this SO, your custom implementation will be used.</li>
<li> b) a clientside initiated SO is a &#8220;generic&#8221; SO that red5 automatically creates right in the moment when red5 recognizes that the SO a client  connects does not exist.</li>
</ul>
<p>The problem arises when you want to create a custom serverside SO for the main application:<br />
e.g. I want to create an SO named &#8220;chat&#8221; in the main application scope and add a listener to it. So i put the following lines in my appStart method:</p>
<pre>createSharedObject(scope, "chat", false);
ISharedObject so = getSharedObject(scope, "chat");
ISharedObjectListener listener = new MyCustomListener();
so.addSharedObjectListener(listener);</pre>
<p>Now when i start the server, <strong>appStart</strong> is called once the Application starts. My custom SO named &#8220;chat &#8221; will be created (a serverside-initiated SO). Now when a client connects to the SO named &#8220;chat&#8221; in the main application scope, my custom SO will be used by red5. Everything works fine untill now.<br />
But when all clients disconnect form this SO, my custom, serverside initiated SO will be destroyed by red5. After that, when a client connects to the SO named &#8220;chat&#8221;, red5 won&#8217;t find it anymore and will automatically create a new &#8220;genric&#8221; one. This new one now is clientside initiated, as i did not create it in the serverside code with createSharedObject. The difference now is, that no listener is attached to the new generic SO, and so no events will be fired anymore.</p>
<p>This problem is not that severe for SOs in a room scope. In this case you put your creation code inside the <strong>roomStart</strong> method. As the room is also destroyed when the last connected client disconnects, the roomStart method will be called multiple times during the application lifecycle, i.e. everytime the first client connects to a room. In this case the problem only arises when the last client disconnects from the SO but not the room.</p>
<h3>So what solution is there to this problem?</h3>
<p>It would be good to have something like a SharedObjectCreationHandler or a SharedObjectFactory, but unfortunately there is nothing like that. But there is a Handler which  handles  sort of SO creation events: the <a href="http://dl.fancycode.com/red5/api/org/red5/server/api/so/ISharedObjectSecurity.html">ISharedObjectSecurity</a>.<br />
This  handler can be registered in the Application by <a href="http://dl.fancycode.com/red5/api/org/red5/server/adapter/MultiThreadedApplicationAdapter.html#registerSharedObjectSecurity%28org.red5.server.api.so.ISharedObjectSecurity%29">registerSharedObjectSecurity</a>. Its use is to controll access to shared objects. It contains an event method named <strong>isCreationAllowed</strong>: Prior to automatically creating a SO red5 checks if creation is allowed by calling this method.<br />
Now if you want  a custom serverside initiated SO to be created everytime red5 automatically tries to create a SO, you can put your SO creation code inside this method and return true. Red5 then knows creation is allowed and tries to create a SO. To do this red5f first checks if the SO already exists and !big surprise! it does, so red5 uses it and does not create one on its own.</p>
<pre>import static org.red5.server.api.ScopeUtils.getScopeService;
...

  public class MySecurityHandler implements ISharedObjectSecurity
  {

  ...

  public boolean isCreationAllowed(IScope scope, String name, boolean persistent)
  {
    if ( "chat".equals(name) )
    {
      // get the SO creation service. Basically the following lines are exactly
      // what MultiThreadedApplicationAdapter does. You can also pass a reference
      // to your Application to this SecurityHandler and use it instead
      ISharedObjectService service = (ISharedObjectService) getScopeService(
            scope,
            ISharedObjectService.class,
            SharedObjectService.class,
            false
      );

      if( service.createSharedObject(scope, name, persistent) == true )
      {
        ISharedObject so = service.getSharedObject(scope, name);
        ISharedObjectListener listener = new MyCustomListener();
        so.addSharedObjectListener(listener);
      }
    }
    return true;
  }

  ...

}</pre>
<p>The method described here, was also discussed in: <a href="http://osflash.org/pipermail/red5_osflash.org/2008-February/018579.html">[Red5] creation handler to ShareObject</a></p>
<h3>Last but not the least: When is it better to use a SharedObject and when to use   invokes?</h3>
<p>Here is good mail discussing that topic: <em><a href="http://osflash.org/pipermail/red5_osflash.org/2007-August/014406.html" target="_blank">http://osflash.org/pipermail/red5_osflash.org/2007-August/014406.html</a></em></p>
<p>That&#8217;s all,<br />
hopefully it helps somebody.</p>
<p>Cheers,<br />
Nik</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Further tutorials on SOs:</p>
<ul>
<li><a href="http://faindu.wordpress.com/2007/07/09/what-are-remote-shared-object-rso-for/" target="_blank">What are Remote Shared Objects (RSO) for?</a></li>
<li><a href="http://www.joachim-bauch.de/tutorials/red5/MigrationGuide.txt#sharedobjects" target="_blank">http://www.joachim-bauch.de/tutorials/red5/MigrationGuide.txt#sharedobjects</a></li>
<li><a href="http://www.joachim-bauch.de/tutorials/red5/HOWTO-Security.txt#shared-objects" target="_blank">http://www.joachim-bauch.de/tutorials/red5/HOWTO-Security.txt#shared-objects</a></li>
<li><a href="http://sunil-gupta.blogspot.com/2007/04/shared-whiteboard-application-in-red5.html" target="_blank">Shared Whiteboard application in Red5</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.zehnet.de/2008/04/11/red5-remote-sharedobject-experience-tips/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>DragController component</title>
		<link>http://www.zehnet.de/2006/05/17/dragcontroller-component/</link>
		<comments>http://www.zehnet.de/2006/05/17/dragcontroller-component/#comments</comments>
		<pubDate>Wed, 17 May 2006 11:40:30 +0000</pubDate>
		<dc:creator>nik</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[as2]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[drag]]></category>
		<category><![CDATA[DragController]]></category>

		<guid isPermaLink="false">http://localhost/zehnet.de/?p=15</guid>
		<description><![CDATA[The DragController component is as flash component that can be used to drag and drop items between several flash ui components, e.g. List, DataGrid, Tree.
With the DragController it is possible to set &#8220;drag and drop&#8221;-references between two components, which define if dragging and dropping from one component to another is possible and what type of [...]]]></description>
			<content:encoded><![CDATA[<p>The DragController component is as flash component that can be used to drag and drop items between several flash ui components, e.g. List, DataGrid, Tree.<br />
With the DragController it is possible to set &#8220;drag and drop&#8221;-references between two components, which define if dragging and dropping from one component to another is possible and what type of items are allowed to be dragged.</p>
<p>It is based on the superb script of Alessandro Crugnola from <a href="http://www.sephiroth.it">sephiroth.it</a> and adds some modifications and improvements, as well as an extensive help provided within the mxp flash extension file.</p>
<p>Have a look at the <strong>demo</strong>, the <strong>help files</strong> and/or <strong>download</strong> the component <a href="http://www.zehnet.de/files/DragController/">here</a>.</p>
<p>Links to the DragController Component on <a href="http://www.sephiroth.it">sephiroth.it</a>:</p>
<ul>
<li><a href="http://www.sephiroth.it/weblog/archives/2006/05/dragcontroller_updated.php">Post: DragController Updated</a></li>
<li><a href="http://www.sephiroth.it/file_detail.php?id=146">Component: DragController</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.zehnet.de/2006/05/17/dragcontroller-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CXS Specification 1.2 (Compact XML Serialization)</title>
		<link>http://www.zehnet.de/2005/03/07/cxs-specification/</link>
		<comments>http://www.zehnet.de/2005/03/07/cxs-specification/#comments</comments>
		<pubDate>Mon, 07 Mar 2005 10:37:21 +0000</pubDate>
		<dc:creator>nik</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[serialization]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://localhost/zehnet.de/?p=161</guid>
		<description><![CDATA[CXS stands for Compact XML        Serialization.
CXS is an XML application for data serialization developed by zehnet which offers the possibility        of transferring complex data structures between programming environments.
The process of creating an XML representation of application data is called serialization.
The process [...]]]></description>
			<content:encoded><![CDATA[<p>CXS stands for <strong>C</strong>ompact <strong>X</strong>ML        <strong>S</strong>erialization.</p>
<p>CXS is an XML application for data serialization developed by <a href="http://www.zehnet.de">zehnet</a> which offers the possibility        of transferring complex data structures between programming environments.</p>
<p>The process of creating an XML representation of application data is called serialization.<br />
The process of instantiating data from an XML representation is called unserialization.<br />
CXS adapts <a href="http://www.php.net/serialize" target="_blank">PHP&#8217;s serialization</a> structure  to XML and extends this structure with some data types known from <a href="http://en.wikipedia.org/wiki/WDDX" target="_blank">WDDX</a>.</p>
<p>CXS is aimed to offer a representation of data structures which is compact        (i.e. few bytes, little overhead) and effectively to parse in different programming environments.<br />
<em>The idea for CXS was to build up a serialization scheme for Flash        (client) &#8211; PHP (server) communication, which can be handled easily in both environments and keeps traffic as low as possible.</em></p>
<p>CXS is offered under <a href="http://www.gnu.org/licenses/lgpl-2.1.html" target="_parent"><strong>GNU Lesser General Public License</strong></a> and can be used freely.<span id="more-161"></span></p>
<h2>Syntax</h2>
<p>general characteristics of the syntax:</p>
<ul>
<li>Every XML-element-name or XML-attribute-name has to be <strong>one</strong> ASCII-character            (byte).</li>
<li>Allowed ASCII-characters are the letters <strong>a-z</strong> (ASCII:            97-122). That makes 26 possible names.</li>
<li>XML-element-names and XML-attribute-names are NOT handled case sensitive.<br />
A name            therefore has to satisfy the following regular expression /[a-z]/i</li>
<li>An XML-element is allowed to contain <strong>either</strong> children            <strong>or</strong> character data, not both.</li>
<li>child-elements of the serialized datatypes hash und object have to            be parsed in a two step interval as key-value-pairs.</li>
</ul>
<h2>Data Types</h2>
<p>CXS supports the following data types:</p>
<ul>
<li><strong>scalar types</strong>: <em>string</em>, <em>integer</em>, <em>double</em> (aka. float), <em>boolean</em>, <em>date-time</em></li>
<li><strong>compound types</strong>: <em>array </em>(numerical), <em>hash</em> (associative array), <em>object</em></li>
<li><strong>special types</strong>: <em>null</em></li>
<li><strong>resource types</strong>: <em>binarystream</em></li>
</ul>
<p>Due to the syntax rules described above, every data type is associated with a single         ASCII character.<br />
The following is a list of each data type, its associated character and         the resulting XML representation in CXS.</p>
<table class="borders" border="0">
<tbody>
<tr>
<td><em><strong>type</strong></em></td>
<td align="center"><em><strong>CXS abbreviation</strong></em></td>
<td><em><strong>xml representation</strong></em></td>
</tr>
<tr bgcolor="#f9f9f9">
<td colspan="3"><strong>scalar types:</strong></td>
</tr>
<tr>
<td>(string)</td>
<td align="center"><strong>s</strong></td>
<td>&lt;s&gt;[value]?&lt;/s&gt;</td>
</tr>
<tr>
<td>(boolean)</td>
<td align="center"><strong>b</strong></td>
<td>&lt;b&gt;[value]&lt;/b&gt;</td>
</tr>
<tr>
<td width="0">(integer)</td>
<td width="0" align="center"><strong>i</strong></td>
<td width="0">&lt;i&gt;[value]&lt;/i&gt;</td>
</tr>
<tr>
<td>(double)</td>
<td align="center"><strong>d</strong></td>
<td>&lt;d&gt;[value]&lt;/d&gt;</td>
</tr>
<tr>
<td>(date-time)</td>
<td align="center"><strong>t</strong></td>
<td>&lt;t&gt;[value]&lt;/t&gt;</td>
</tr>
<tr bgcolor="#f9f9f9">
<td colspan="3"><strong>compound types:</strong></td>
</tr>
<tr>
<td>(array)</td>
<td align="center"><strong>a</strong></td>
<td>&lt;a&gt;[value]*&lt;/a&gt;</td>
</tr>
<tr>
<td>(hash)</td>
<td align="center"><strong>h</strong></td>
<td>&lt;h&gt;[key-value-pair]*&lt;/h&gt;</td>
</tr>
<tr>
<td>(object)</td>
<td align="center"><strong>o</strong></td>
<td>&lt;o n=&#8221;[name]&#8220;?&gt;[key-value-pair]*&lt;/o&gt;</td>
</tr>
<tr bgcolor="#f9f9f9">
<td colspan="3"><strong>special type:</strong></td>
</tr>
<tr>
<td>(null)</td>
<td align="center"><strong>n</strong></td>
<td>&lt;n/&gt;</td>
</tr>
<tr bgcolor="#f9f9f9">
<td colspan="3"><strong>resource types:</strong></td>
</tr>
<tr>
<td>(binary)</td>
<td align="center"><strong>c</strong></td>
<td>&lt;c&gt;[value]&lt;/c&gt;</td>
</tr>
</tbody>
</table>
<h2>Data Types and Serialization (CXS Packets)</h2>
<h3>boolean</h3>
<p>a boolean expresses a truth value. It can be either true or false and has to be serialized as 1 or 0.</p>
<pre>&lt;b&gt;1&lt;/b&gt; // for true
&lt;b&gt;0&lt;/b&gt; // for false</pre>
<h3>string</h3>
<p>strings can be of arbitrary length and have to be UTF-8 encoded.</p>
<pre>&lt;s&gt;hello world&lt;/s&gt;</pre>
<h3>null</h3>
<p>null specifies that a variable has no value or is undefined. Languages that do not have the concept of a null value should deserialize nulls as empty strings.</p>
<pre>&lt;n/&gt;</pre>
<h3>date-time</h3>
<p>date-time values have to be serialized according to <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a> in the following format:<br />
Y Y Y Y &#8211; M M &#8211;  	  D D T H H :  	  M M :  S S +  	   H H : M M<br />
( Y = year, M = month, D = day, H = hour, M = minute, S = second, T = separator of date and time )<br />
the last 2 HH indicate the timezone offset from UTC which has to be prefixed by a + (positive) or &#8211; (negative) to indicate the deviation direction.<br />
A leading 0 is not obligatory for months, days, hours, minutes or seconds encodings.</p>
<pre>&lt;t&gt;2000-02-15T09:30:25+01:00&lt;/t&gt;</pre>
<h3>array</h3>
<p>an array is a numerically (integer) indexed list of data elements, usually with a starting index value of 0.<br />
Arrays will be serialized as one parent array XML element containing the list of data elements as CXS serialized children.</p>
<p><strong>Example 1:</strong> The following array</p>
<pre>$test = array( 'value1', 'value2', 3 );</pre>
<p>will be serialized to the CXS packet</p>
<pre>&lt;a&gt;
   &lt;s&gt;value1&lt;/s&gt;
   &lt;s&gt;value2&lt;/s&gt;
   &lt;i&gt;3&lt;/i&gt;
&lt;/a&gt;</pre>
<p>Some programming languages demand each list element to be of the same data type.<br />
If an array matches this restriction the flag attribute t=&#8221;[type]&#8221; can <strong>optionally</strong> be added to the CXS representation of the array. The value of the attribute <strong>t</strong> has to be the CXS type indicator (s for Strings, i for Integers, &#8230;)</p>
<p><strong>Example 2:</strong> As the following array consists of elements which are all of the same type (integer), the attribute t=&#8221;i&#8221; can be added.</p>
<pre>$test = array( 1, 2, 3 );</pre>
<p>can be serialized to the CXS packet</p>
<pre>&lt;a t="i"&gt;
   &lt;i&gt;1&lt;/i&gt;
   &lt;i&gt;2&lt;/i&gt;
   &lt;i&gt;3&lt;/i&gt;
&lt;/a&gt;</pre>
<h3>hash</h3>
<p>a hash is also known as associative array and is a string indexed list of data elements.<br />
Hashes are serialized as key-value-pairs. Each hash element will result in one key and one value XML element.</p>
<p><strong>Example 3:</strong> The following hash (associative array)</p>
<pre>$test = array( 'var1' =&gt; 'value1', 'var2' =&gt; 'value2' );</pre>
<p>will be serialized to the CXS packet</p>
<pre>&lt;h&gt;
   &lt;s&gt;var1&lt;/s&gt;
   &lt;s&gt;value1&lt;/s&gt;
   &lt;s&gt;var2&lt;/s&gt;
   &lt;s&gt;value2&lt;/s&gt;
&lt;/h&gt;</pre>
<p>As some programming languages (e.g. PHP) do not strictly separate between array and hash, arrays can also be serialized in the CXS hash serialization scheme. CXS parsers could offer the option to define whether a strict differentiation should occur or not.</p>
<p><strong>Example 4:</strong> The following array of example 1</p>
<pre>$test = array( 'value1', 'value2', 3 );</pre>
<p>will be serialized to the CXS packet</p>
<pre>&lt;h&gt;
   &lt;i&gt;0&lt;/i&gt;
   &lt;s&gt;value1&lt;/s&gt;
   &lt;i&gt;1&lt;/i&gt;
   &lt;s&gt;value2&lt;/s&gt;
   &lt;i&gt;2&lt;/i&gt;
   &lt;i&gt;3&lt;/i&gt;
&lt;/h&gt;</pre>
<h3>object</h3>
<p>objects are serialized like hashes (associative arrays) except that the class name is stored as attribute n (name).<br />
If a CXS parser is deserializing an object providing the name attribute it should look for a class with this name and instantiate the named object with the deserialized values if found. Anonym / Standard objects will be serialized without this attribute.</p>
<p><strong>Example 5:</strong> The following php object $myClass</p>
<pre>class test {
   var $var1 = 'value1';
   function test(){
      $this-&gt;var2 = 'value2';
   }
}
$myClass = new test();</pre>
<p>will be serialized to the CXS packet</p>
<pre>&lt;o&gt;
   &lt;s&gt;var1&lt;/s&gt;
   &lt;s&gt;value1&lt;/s&gt;
   &lt;s&gt;var2&lt;/s&gt;
   &lt;s&gt;value2&lt;/s&gt;
&lt;/o&gt;</pre>
<p>if the name attribute is provided deserializing would result in a new instance of test.</p>
<pre>&lt;o n="test"&gt;
   &lt;s&gt;var1&lt;/s&gt;
   &lt;s&gt;value1&lt;/s&gt;
   &lt;s&gt;var2&lt;/s&gt;
   &lt;s&gt;value2&lt;/s&gt;
&lt;/o&gt;</pre>
<h3>binary</h3>
<p>the binary datatype represents strings of binary data. Binary data has to be <strong>base64</strong> encoded. This will ensure compatibility with general XML UTF-8 encoding.</p>
<p><strong>Example 6:</strong> The php file resource</p>
<pre>$file_resource = fopen('myFile', "r");
$CXS-&gt;serialize($file_resource);</pre>
<p>will e.g. be serialized to the CXS packet</p>
<pre>&lt;c&gt;Tm9ydG9uIEFudGlWaXJ1cyBoYXQgZm9sZ2VuZGV&lt;/c&gt;</pre>
<h2>CXS Envelope</h2>
<p>The CXS envelope surrounds CXS serialized data and indicates that all child nodes are CXS serialized.<br />
If CXS serialized data is part of an XML document containing other data besides CXS, a parser should search for a CXS envelope and start parsing its children.<br />
The CXS envelope is an XML-element with the name <strong>cxs</strong> and one attribute indicating the CXS version used for serialization. This attribute is obligatory.</p>
<pre>&lt;cxs v="1.1"&gt;
  <span style="color: #999999;">&lt;!-- CXS serialized data as child --&gt;</span>
&lt;/cxs&gt;</pre>
<p>If the whole XML document is CXS, you can omit the envelope and simply use a single CXS packet instead.</p>
<h2>Document Type Declaration (DTD)</h2>
<p>The following DTD can be used to validate CXS serialized data:</p>
<pre>  &lt;!DOCTYPE cxs [
     &lt;!ELEMENT cxs (a|h|o|s|b|i|d|t|n|c)&gt;
     &lt;!ATTLIST cxs
               v CDATA #FIXED "1.1"&gt;
     &lt;!ELEMENT s (#PCDATA)&gt;
     &lt;!ELEMENT b (#PCDATA)&gt;
     &lt;!ELEMENT i (#PCDATA)&gt;
     &lt;!ELEMENT d (#PCDATA)&gt;
     &lt;!ELEMENT t (#PCDATA)&gt;
     &lt;!ELEMENT n EMPTY&gt;
     &lt;!ELEMENT a (a|h|o|s|b|i|d|t|n|r|c)*&gt;
     &lt;!ATTLIST a
               l CDATA #IMPLIED
               f CDATA #IMPLIED&gt;
     &lt;!ELEMENT h (a|h|o|s|b|i|d|t|n|r|c)*&gt;
     &lt;!ELEMENT o (a|h|o|s|b|i|d|t|n|r|c)*&gt;
     &lt;!ATTLIST o
               n CDATA #IMPLIED&gt;
     &lt;!ELEMENT c (#PCDATA)&gt;
  ]&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.zehnet.de/2005/03/07/cxs-specification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unicode, UTF-8 tutorial</title>
		<link>http://www.zehnet.de/2005/02/12/unicode-utf-8-tutorial/</link>
		<comments>http://www.zehnet.de/2005/02/12/unicode-utf-8-tutorial/#comments</comments>
		<pubDate>Sat, 12 Feb 2005 14:54:34 +0000</pubDate>
		<dc:creator>nik</dc:creator>
				<category><![CDATA[tutorials]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[character set]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://localhost/zehnet.de/?p=195</guid>
		<description><![CDATA[This tutorial covers Unicode and its UTF-8 mapping standard. It will start at zero with explaining bits and binary structures, followed by an explanation   of the ASCII, extended ASCII and Unicode character sets and ending with some conclusions on how to use UTF-8 en-/decoding with Flash &#38; PHP.

What are bytes and bits?
Bit means [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.zehnet.de/_blog/assets/unicode-tutorial/unicode-header.jpg" alt="UTF8 Tutorial" /></p>
<p>This tutorial covers Unicode and its UTF-8 mapping standard. It will start at zero with explaining bits and binary structures, followed by an explanation   of the ASCII, extended ASCII and Unicode character sets and ending with some conclusions on how to use UTF-8 en-/decoding with Flash &amp; PHP.</p>
<p><span id="more-195"></span></p>
<h2>What are bytes and bits?</h2>
<p><strong>Bit</strong> means &#8220;binary digit&#8221; and is the smallest unit of computerized data. A bit is a 2-base number, i.e. it has either the value of 0 or 1.<br />
A <strong>byte</strong> is an amount of memory, a certain collection of bits, originally variable in size but now almost always eight bits. This makes 2<sup>8</sup> or 256 possible values for a byte.</p>
<table class="borders" border="0">
<tbody>
<tr>
<td rowspan="3">byte =</td>
<td width="25" align="center" bgcolor="#f9f9f9">1</td>
<td width="25" align="center" bgcolor="#f9f9f9">2</td>
<td width="25" align="center" bgcolor="#f9f9f9">3</td>
<td width="25" align="center" bgcolor="#f9f9f9">4</td>
<td width="25" align="center" bgcolor="#f9f9f9">5</td>
<td width="25" align="center" bgcolor="#f9f9f9">6</td>
<td width="25" align="center" bgcolor="#f9f9f9">7</td>
<td width="25" align="center" bgcolor="#f9f9f9">8</td>
</tr>
<tr>
<td align="center">bit</td>
<td align="center">bit</td>
<td align="center">bit</td>
<td align="center">bit</td>
<td align="center">bit</td>
<td align="center">bit</td>
<td align="center">bit</td>
<td align="center">bit</td>
</tr>
<tr>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
</tr>
</tbody>
</table>
<p>Some example bytes could be 00000001 or 11111111 or 01010011.<br />
Now how can we calculate the decimal value of this binary encoded byte. What we need is a conversion from base 2 to base 10.<br />
Every 1 or 0 of these binary values is associated with an exponential of 2. For 8 bits it looks like the following:</p>
<table class="borders" border="0">
<tbody>
<tr>
<td rowspan="3">byte =</td>
<td width="50" align="center" bgcolor="#f9f9f9">1</td>
<td width="50" align="center" bgcolor="#f9f9f9">2</td>
<td width="50" align="center" bgcolor="#f9f9f9">3</td>
<td width="50" align="center" bgcolor="#f9f9f9">4</td>
<td width="50" align="center" bgcolor="#f9f9f9">5</td>
<td width="50" align="center" bgcolor="#f9f9f9">6</td>
<td width="50" align="center" bgcolor="#f9f9f9">7</td>
<td width="50" align="center" bgcolor="#f9f9f9">8</td>
</tr>
<tr>
<td align="center"><strong>128 </strong>(2<sup>7</sup>)</td>
<td align="center"><strong>64</strong> (2<sup>6</sup>)</td>
<td align="center"><strong>32 </strong>(2<sup>5</sup>)</td>
<td align="center"><strong>16 </strong>(2<sup>4</sup>)</td>
<td align="center"><strong>8 </strong>(2<sup>3</sup>)</td>
<td align="center"><strong>4 </strong>(2<sup>2</sup>)</td>
<td align="center"><strong>2</strong> (2<sup>1</sup>)</td>
<td align="center"><strong>1 </strong>(2<sup>0</sup>)</td>
</tr>
<tr>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
<td align="center">1|0</td>
</tr>
</tbody>
</table>
<p>The calculation of the decimal equivalent of the binary value 00000001:</p>
<table class="borders" border="0">
<tbody>
<tr>
<td rowspan="2">byte =</td>
<td width="25" align="center"><strong>128</strong></td>
<td width="25" align="center"><strong>64</strong></td>
<td width="25" align="center"><strong>32</strong></td>
<td width="25" align="center"><strong>16</strong></td>
<td width="25" align="center"><strong>8</strong></td>
<td width="25" align="center"><strong>4</strong></td>
<td width="25" align="center"><strong>2</strong></td>
<td width="25" align="center"><strong>1</strong></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">= 1</td>
</tr>
</tbody>
</table>
<p>The calculation of the decimal equivalent of the binary value 11111111:</p>
<table class="borders" border="0">
<tbody>
<tr>
<td rowspan="2">byte =</td>
<td width="25" align="center"><strong>128</strong></td>
<td width="25" align="center"><strong>64</strong></td>
<td width="25" align="center"><strong>32</strong></td>
<td width="25" align="center"><strong>16</strong></td>
<td width="25" align="center"><strong>8</strong></td>
<td width="25" align="center"><strong>4</strong></td>
<td width="25" align="center"><strong>2</strong></td>
<td width="25" align="center"><strong>1</strong></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">= 128+64+32+16+8+4+2+1 = 255</td>
</tr>
</tbody>
</table>
<p>The calculation of the decimal equivalent of the binary value 01010011:</p>
<table class="borders" border="0">
<tbody>
<tr>
<td rowspan="2">byte =</td>
<td width="25" align="center"><strong>128</strong></td>
<td width="25" align="center"><strong>64</strong></td>
<td width="25" align="center"><strong>32</strong></td>
<td width="25" align="center"><strong>16</strong></td>
<td width="25" align="center"><strong>8</strong></td>
<td width="25" align="center"><strong>4</strong></td>
<td width="25" align="center"><strong>2</strong></td>
<td width="25" align="center"><strong>1</strong></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">= 64+16+2+1 = 83</td>
</tr>
</tbody>
</table>
<h2>What is ASCII?</h2>
<p><strong>ASCII</strong> stands for American Standard Code for Information        Interchange and is a standard for assigning numerical values to the set        of letters in the Roman alphabet and typographic characters. The <span class="hl">ASCII</span> character set can be represented by 7 bits. This makes 2<sup>7</sup> or 128 different values resp. characters.<br />
As <span class="hl">ASCII</span> uses only 7 of the 8 bits available of an byte the first bit is always 0: 0xxxxxxx;<br />
Below there is a table of decimal values, their binary expressions and the character assigned to that value due to the <span class="hl">ASCII</span> standard. The first 32 characters are control characters.</p>
<table class="borders" border="0">
<tbody>
<tr bgcolor="#f9f9f9">
<td>dec</td>
<td>bin</td>
<td>char</td>
<td>dec</td>
<td>bin</td>
<td>char</td>
</tr>
<tr>
<td bgcolor="#f9f9f9">0</td>
<td>00000000</td>
<td><strong>NUL (null)</strong></td>
<td bgcolor="#f9f9f9">64</td>
<td>01000000</td>
<td><strong>@</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">1</td>
<td>00000001</td>
<td><strong>SOH (start of heading)</strong></td>
<td bgcolor="#f9f9f9">65</td>
<td>01000001</td>
<td><strong>A</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">2</td>
<td>00000010</td>
<td><strong>STX (start of text)</strong></td>
<td bgcolor="#f9f9f9">66</td>
<td>01000010</td>
<td><strong>B</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">3</td>
<td>00000011</td>
<td><strong>ETX (end of text)</strong></td>
<td bgcolor="#f9f9f9">67</td>
<td>01000011</td>
<td><strong>C</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">4</td>
<td>00000100</td>
<td><strong>EOT (end of transmission)</strong></td>
<td bgcolor="#f9f9f9">68</td>
<td>01000100</td>
<td><strong>D</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">5</td>
<td>00000101</td>
<td><strong>ENQ (enquiry)</strong></td>
<td bgcolor="#f9f9f9">69</td>
<td>01000101</td>
<td><strong>E</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">6</td>
<td>00000110</td>
<td><strong>ACK (acknowledge)</strong></td>
<td bgcolor="#f9f9f9">70</td>
<td>01000110</td>
<td><strong>F</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">7</td>
<td>00000111</td>
<td><strong>BEL (bell)</strong></td>
<td bgcolor="#f9f9f9">71</td>
<td>01000111</td>
<td><strong>G</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">8</td>
<td>00001000</td>
<td><strong>BS (backspace)</strong></td>
<td bgcolor="#f9f9f9">72</td>
<td>01001000</td>
<td><strong>H</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">9</td>
<td>00001001</td>
<td><strong>TAB (horizontal tab)</strong></td>
<td bgcolor="#f9f9f9">73</td>
<td>01001001</td>
<td><strong>I</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">10</td>
<td>00001010</td>
<td><strong>LF (NL line feed, new line)</strong></td>
<td bgcolor="#f9f9f9">74</td>
<td>01001010</td>
<td><strong>J</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">11</td>
<td>00001011</td>
<td><strong>VT (vertical tab</strong></td>
<td bgcolor="#f9f9f9">75</td>
<td>01001011</td>
<td><strong>K</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">12</td>
<td>00001100</td>
<td><strong>FF (NP form feed, new page)</strong></td>
<td bgcolor="#f9f9f9">76</td>
<td>01001100</td>
<td><strong>L</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">13</td>
<td>00001101</td>
<td><strong>CR (carriage return)</strong></td>
<td bgcolor="#f9f9f9">77</td>
<td>01001101</td>
<td><strong>M</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">14</td>
<td>00001110</td>
<td><strong>SO (shift out)</strong></td>
<td bgcolor="#f9f9f9">78</td>
<td>01001110</td>
<td><strong>N</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">15</td>
<td>00001111</td>
<td><strong>SI (shift in)</strong></td>
<td bgcolor="#f9f9f9">79</td>
<td>01001111</td>
<td><strong>O</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">16</td>
<td>00010000</td>
<td><strong>DLE (data link escape)</strong></td>
<td bgcolor="#f9f9f9">80</td>
<td>01010000</td>
<td><strong>P</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">17</td>
<td>00010001</td>
<td><strong>DC1 (device control 1)</strong></td>
<td bgcolor="#f9f9f9">81</td>
<td>01010001</td>
<td><strong>Q</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">18</td>
<td>00010010</td>
<td><strong>DC2 (device control 2)</strong></td>
<td bgcolor="#f9f9f9">82</td>
<td>01010010</td>
<td><strong>R</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">19</td>
<td>00010011</td>
<td><strong>DC3 (device control 3)</strong></td>
<td bgcolor="#f9f9f9">83</td>
<td>01010011</td>
<td><strong>S</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">20</td>
<td>00010100</td>
<td><strong>DC4 (device control 4)</strong></td>
<td bgcolor="#f9f9f9">84</td>
<td>01010100</td>
<td><strong>T</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">21</td>
<td>00010101</td>
<td><strong>NAK (negative acknowledge)</strong></td>
<td bgcolor="#f9f9f9">85</td>
<td>01010101</td>
<td><strong>U</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">22</td>
<td>00010110</td>
<td><strong>SYN (synchronous idle)</strong></td>
<td bgcolor="#f9f9f9">86</td>
<td>01010110</td>
<td><strong>V</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">23</td>
<td>00010111</td>
<td><strong>ETB (end of trans. block)</strong></td>
<td bgcolor="#f9f9f9">87</td>
<td>01010111</td>
<td><strong>W</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">24</td>
<td>00011000</td>
<td><strong>CAN (cancel)</strong></td>
<td bgcolor="#f9f9f9">88</td>
<td>01011000</td>
<td><strong>X</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">25</td>
<td>00011001</td>
<td><strong>EM (end of medium)</strong></td>
<td bgcolor="#f9f9f9">89</td>
<td>01011001</td>
<td><strong>Y</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">26</td>
<td>00011010</td>
<td><strong>SUB (substitute)</strong></td>
<td bgcolor="#f9f9f9">90</td>
<td>01011010</td>
<td><strong>Z</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">27</td>
<td>00011011</td>
<td><strong>ESC (escape)</strong></td>
<td bgcolor="#f9f9f9">91</td>
<td>01011011</td>
<td><strong>[</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">28</td>
<td>00011100</td>
<td><strong>FS (file separator)</strong></td>
<td bgcolor="#f9f9f9">92</td>
<td>01011100</td>
<td><strong></strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">29</td>
<td>00011101</td>
<td><strong>GS (group separator)</strong></td>
<td bgcolor="#f9f9f9">93</td>
<td>01011101</td>
<td><strong>]</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">30</td>
<td>00011110</td>
<td><strong>RS (record separator)</strong></td>
<td bgcolor="#f9f9f9">94</td>
<td>01011110</td>
<td><strong>^</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">31</td>
<td>00011111</td>
<td><strong>US (unit separator)</strong></td>
<td bgcolor="#f9f9f9">95</td>
<td>01011111</td>
<td><strong>_</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">32</td>
<td>00100000</td>
<td><strong>SPACE</strong></td>
<td bgcolor="#f9f9f9">96</td>
<td>01100000</td>
<td><strong>`</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">33</td>
<td>00100001</td>
<td><strong>!</strong></td>
<td bgcolor="#f9f9f9">97</td>
<td>01100001</td>
<td><strong>a</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">34</td>
<td>00100010</td>
<td><strong>&#8220;</strong></td>
<td bgcolor="#f9f9f9">98</td>
<td>01100010</td>
<td><strong>b</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">35</td>
<td>00100011</td>
<td><strong>#</strong></td>
<td bgcolor="#f9f9f9">99</td>
<td>01100011</td>
<td><strong>c</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">36</td>
<td>00100100</td>
<td><strong>$</strong></td>
<td bgcolor="#f9f9f9">100</td>
<td>01100100</td>
<td><strong>d</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">37</td>
<td>00100101</td>
<td><strong>%</strong></td>
<td bgcolor="#f9f9f9">101</td>
<td>01100101</td>
<td><strong>e</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">38</td>
<td>00100110</td>
<td><strong>&amp;</strong></td>
<td bgcolor="#f9f9f9">102</td>
<td>01100110</td>
<td><strong>f</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">39</td>
<td>00100111</td>
<td><strong>&#8216;</strong></td>
<td bgcolor="#f9f9f9">103</td>
<td>01100111</td>
<td><strong>g</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">40</td>
<td>00101000</td>
<td><strong>(</strong></td>
<td bgcolor="#f9f9f9">104</td>
<td>01101000</td>
<td><strong>h</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">41</td>
<td>00101001</td>
<td><strong>)</strong></td>
<td bgcolor="#f9f9f9">105</td>
<td>01101001</td>
<td><strong>i</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">42</td>
<td>00101010</td>
<td><strong>*</strong></td>
<td bgcolor="#f9f9f9">106</td>
<td>01101010</td>
<td><strong>j</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">43</td>
<td>00101011</td>
<td><strong>+</strong></td>
<td bgcolor="#f9f9f9">107</td>
<td>01101011</td>
<td><strong>k</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">44</td>
<td>00101100</td>
<td><strong>,</strong></td>
<td bgcolor="#f9f9f9">108</td>
<td>01101100</td>
<td><strong>l</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">45</td>
<td>00101101</td>
<td><strong>-</strong></td>
<td bgcolor="#f9f9f9">109</td>
<td>01101101</td>
<td><strong>m</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">46</td>
<td>00101110</td>
<td><strong>.</strong></td>
<td bgcolor="#f9f9f9">110</td>
<td>01101110</td>
<td><strong>n</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">47</td>
<td>00101111</td>
<td><strong>/</strong></td>
<td bgcolor="#f9f9f9">111</td>
<td>01101111</td>
<td><strong>o</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">48</td>
<td>00110000</td>
<td><strong>0</strong></td>
<td bgcolor="#f9f9f9">112</td>
<td>01110000</td>
<td><strong>p</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">49</td>
<td>00110001</td>
<td><strong>1</strong></td>
<td bgcolor="#f9f9f9">113</td>
<td>01110001</td>
<td><strong>q</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">50</td>
<td>00110010</td>
<td><strong>2</strong></td>
<td bgcolor="#f9f9f9">114</td>
<td>01110010</td>
<td><strong>r</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">51</td>
<td>00110011</td>
<td><strong>3</strong></td>
<td bgcolor="#f9f9f9">115</td>
<td>01110011</td>
<td><strong>s</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">52</td>
<td>00110100</td>
<td><strong>4</strong></td>
<td bgcolor="#f9f9f9">116</td>
<td>01110100</td>
<td><strong>t</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">53</td>
<td>00110101</td>
<td><strong>5</strong></td>
<td bgcolor="#f9f9f9">117</td>
<td>01110101</td>
<td><strong>u</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">54</td>
<td>00110110</td>
<td><strong>6</strong></td>
<td bgcolor="#f9f9f9">118</td>
<td>01110110</td>
<td><strong>v</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">55</td>
<td>00110111</td>
<td><strong>7</strong></td>
<td bgcolor="#f9f9f9">119</td>
<td>01110111</td>
<td><strong>w</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">56</td>
<td>00111000</td>
<td><strong>8</strong></td>
<td bgcolor="#f9f9f9">120</td>
<td>01111000</td>
<td><strong>x</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">57</td>
<td>00111001</td>
<td><strong>9</strong></td>
<td bgcolor="#f9f9f9">121</td>
<td>01111001</td>
<td><strong>y</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">58</td>
<td>00111010</td>
<td><strong>:</strong></td>
<td bgcolor="#f9f9f9">122</td>
<td>01111010</td>
<td><strong>z</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">59</td>
<td>00111011</td>
<td><strong>;</strong></td>
<td bgcolor="#f9f9f9">123</td>
<td>01111011</td>
<td><strong>(</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">60</td>
<td>00111100</td>
<td><strong>&lt;</strong></td>
<td bgcolor="#f9f9f9">124</td>
<td>01111100</td>
<td><strong>|</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">61</td>
<td>00111101</td>
<td><strong>=</strong></td>
<td bgcolor="#f9f9f9">125</td>
<td>01111101</td>
<td><strong>)</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">62</td>
<td>00111110</td>
<td><strong>&gt;</strong></td>
<td bgcolor="#f9f9f9">126</td>
<td>01111110</td>
<td><strong>~</strong></td>
</tr>
<tr>
<td bgcolor="#f9f9f9">63</td>
<td>00111111</td>
<td><strong>?</strong></td>
<td bgcolor="#f9f9f9">127</td>
<td>01111111</td>
<td><strong>DEL</strong></td>
</tr>
</tbody>
</table>
<h2>What is extended ASCII?</h2>
<blockquote><p>&#8220;Because the number of written symbols used in common natural languages        far exceeds the limited range of the <span class="hl">ASCII</span> code,        many extensions to it have been used to facilitate handling of those languages.        Foreign markets for computers and communication equipment were historically        open long before standards bodies had time to deliberate upon the best way        to accommodate them, so there are many incompatible proprietary extensions        to <span class="hl">ASCII</span>.</p>
<p>Since <span class="hl">ASCII</span> is a 7-bit code, and most computers          manipulate data in 8-bit bytes, many extensions use the additional 128          codes available by using all 8 bits of each byte. This helps include many          languages otherwise not easily representable in <span class="hl">ASCII</span>,          but still not enough to cover all languages of countries in which computers          are sold, so even these 8-bit extensions had to have local variants.&#8221;</p>
<p>&#8220;Eventually, ISO released its <strong>ISO 8859</strong> standards          describing its own set of 8-bit <span class="hl">ASCII extensions</span>.          The most popular was <strong>ISO 8859-1</strong>, also called <strong>ISO          Latin1</strong>, which contained characters sufficient for the most common          Western European languages. Variations were standardized for other languages          as well: ISO 8859-2 for Eastern European languages and ISO 8859-5 for          Cyrillic languages, for example.&#8221;<br />
(<a href="http://www.answers.com/main/ntquery?dsid=2222&amp;dekey=Extended%2BASCII" target="_blank">source          link: answers.com</a>)</p></blockquote>
<p>Often the term <span class="hl">ASCII</span> is associated with the          8 bit <span class="hl">ISO 8859</span> standards. For the rest of          the document i will refer to the 7 bit standard as <span class="hl">ASCII</span> and to the 8 bit <span class="hl">ISO 8859</span> standards as <span class="hl">extended          ASCII</span>.</p>
<h2>What is Unicode?</h2>
<p><strong>Unicode</strong> is the attempt to create a single unified character        set. <span class="hl">Unicode</span> is a means to assign a unique number        for all characters used by humans in written language. The <span class="hl">Unicode</span> standard is basically nothing but tables listing every charcter in written        language with its corresponding unique number. One do not need to say that        this amount of characters by far exceeds 256 and one byte will not suffice        to represent all these characters. Several mechanisms have therefore been        suggested to implement <span class="hl">Unicode</span>, i.e. to represent        these unique numbers as a sequence of bytes.</p>
<p>These mapping methods are called the <strong>UTF (Unicode Transformation        Format)</strong>. Among them are <strong>UTF-8, UTF-16, UTF-32</strong>.        The numbers indicate the number of bits in one unit. So <span class="hl">UTF-8</span> uses 8 bits per unit. This corresponds to the bits used by one byte as described        above and is therefore best processed by our operating system. Hence <span class="hl">UTF-8</span> emerged to the standard encoding        for interchange of unicode text with UTF-16 and UTF-32 being used mainly        for internal processing.</p>
<h2>What is UTF-8?</h2>
<p><span class="hl">UTF-8</span> is a mapping method to represent all Unicode        characters as a sequence of bytes.<br />
<span class="hl">UTF-8</span> has the following properties:</p>
<blockquote>
<ul>
<li> <span class="hl">Unicode</span> characters U+0000 (00000000)            to U+007F (01111111) are encoded simply as bytes 0&#215;00 to 0&#215;7F (<span class="hl">ASCII</span> compatibility). This means that files and strings which contain only            7-bit ASCII characters have the same encoding under both ASCII and UTF-8.            This makes UTF-8 a superset of ASCII.</li>
<li> All Unicode characters &gt;U+007F are encoded as a sequence of several bytes,        		each of which has the most significant bit set. Therefore, no ASCII byte        		(0&#215;00-0&#215;7F) can appear as part of any other character.</li>
<li> The first byte of a multibyte sequence that represents a non-ASCII character  			is always in the range 0xC0 (11000000) to 0xFD (11111101) and it indicates how many bytes follow  			for this character. All further bytes in a multibyte sequence are in the  			range 0&#215;80 (10000000) to 0xBF (10111111). This allows easy resynchronization and makes the encoding  			stateless and robust against missing bytes.</li>
<li> All possible 2<sup>31</sup> Unicode codes can be encoded.</li>
<li> UTF-8 encoded characters may theoretically be up to six bytes long, however  			16-bit BMP characters are only up to three bytes long.</li>
<li> The sorting order of Bigendian UCS-4 byte strings is preserved.</li>
<li> The bytes 0xFE (11111110) and 0xFF (11111111) are never used in the UTF-8 encoding.</li>
</ul>
<p>(<a href="http://www.cl.cam.ac.uk/%7Emgk25/unicode.html" target="_blank">source        link: www.cl.cam.ac.uk</a>)</p></blockquote>
<p>So what does all this mean? As we have learned above <span class="hl">ASCII</span> characters can be represented by 7 bits. Hence a 8 bit representation of        <span class="hl">ASCII</span> characters will always have a leading        0 (0xxxxxxx). At this point <span class="hl">UTF-8</span> comes in.        <span class="hl">UTF-8</span> encodes all <span class="hl">ASCII</span> as is. There will be no change. To indicate that a character is NOT part        of the <span class="hl">ASCII</span> charset the leading 0 will be changed        to an 1. So an <span class="hl">UTF-8</span> character which is not        part of <span class="hl">ASCII</span> will always start with a 1.</p>
<p>Furthermore the first byte (8 bits) of a byte sequence used to repesent        a <span class="hl">Unicode</span> character also indicates how many        bytes of this sequence will follow. E.g. 110xxxxx: the first 1 indicates        that it is not an <span class="hl">ASCII</span> character, the second        1 indicates that the next byte belongs to the encoding of this unicode character.        1110xxxx: again the first byte indicates that it is not an <span class="hl">ASCII</span> character, the following two 1 indicate that the next two bytes belong to        the encoding of this Unicode character. And so on.</p>
<p>The following table makes it clear:</p>
<table class="borders" border="0">
<tbody>
<tr>
<td><strong>Unicode character number (decimal)</strong></td>
<td><strong>bit sequence</strong></td>
</tr>
<tr>
<td>U-0 &#8211; U-127:</td>
<td>0xxxxxxx (ASCII characters)</td>
</tr>
<tr>
<td>U-128 &#8211; U-2047:</td>
<td>110xxxxx 10xxxxxx</td>
</tr>
<tr>
<td>U-2048 &#8211; U-65535:</td>
<td>1110xxxx 10xxxxxx 10xxxxxx</td>
</tr>
<tr>
<td>U-65536 &#8211; U-2097151:</td>
<td>11110xxx 10xxxxxx 10xxxxxx 10xxxxxx</td>
</tr>
<tr>
<td>U-2097152 &#8211; U-67108863:</td>
<td>111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx</td>
</tr>
<tr>
<td>U-67108864 &#8211; U-2147483647:</td>
<td>1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx</td>
</tr>
</tbody>
</table>
<h2>UTF-8 example</h2>
<p>The first thing that becomes clear is that you cannot analyze a string wether it is encoded in <span class="hl">UTF-8</span> or <span class="hl">ISO        8859</span>. No check can be done to find out if a string is already <span class="hl">UTF-8</span> encoded or not. Well you can check if the string is valid UTF-8 and hence assume it is UTF-8. A function which does that can be found in the comments to the utf8_encode in the php manual. Validating UTF-8 takes processing        time and the result leaves room for discussion as it could also be an accidently valid <span class="hl">ISO 8859</span> string. This string would mostly consist of some weird signs because then they are all part of the <span class="hl">extended  ASCII</span> charset (starting with a 1).<br />
But again, you never can be sure.</p>
<h3>Let&#8217;s make an example:</h3>
<p>Take a look at the following string: &#8220;© by München&#8221;.<br />
München is the german word for Munich. This string contains two characters which are not part of the <span class="hl">ASCII</span> charset: the © and the ü.<br />
These characters are part of the <span class="hl">extended ASCII</span> charset <span class="hl">ISO 8859-1</span>. As this string is not yet encoded to <span class="hl">UTF-8</span> every        character is represented by one byte. So if we encode this string to <span class="hl">UTF-8</span> all bytes/characters        of the <span class="hl">ASCII</span> charset will remain the same, but        the © and the ü are not part of <span class="hl">ASCII</span> but of <span class="hl">extended ASCII</span> and will therefore be        transfered to its <span class="hl">UTF-8</span> equivalent.</p>
<p>Let&#8217;s take a look at the following table:</p>
<table class="borders" border="0">
<tbody>
<tr bgcolor="#f9f9f9">
<td><strong>character</strong></td>
<td><strong>decimal</strong></td>
<td><strong>binary</strong></td>
<td><strong>UTF-8 binary</strong></td>
<td><strong>UTF-8 decimal</strong></td>
<td><strong>UTF-8 interpreted in ISO 8859-1</strong></td>
</tr>
<tr>
<td>®</td>
<td>169</td>
<td>10101001</td>
<td>11000010 10101001</td>
<td>194 169</td>
<td>Â©</td>
</tr>
<tr>
<td>ü</td>
<td>252</td>
<td>11111100</td>
<td>11000011 10111100</td>
<td>195 188</td>
<td>Ã¼</td>
</tr>
</tbody>
</table>
<p>The character ü has the <span class="hl">ISO 8859-1</span> value of 252. Transferred to binary this is 11111100. Now when we encode this        character to <span class="hl">UTF-8</span> it will be represented by two bytes 11000011 and 10111100 or as decimal values 195 and 188.</p>
<p>Back in <span class="hl">ISO 8859-1</span> the character 195 is interpreted as Ã and the character 188 is interpreted as ¼.<br />
Every <span class="hl">UTF-8</span> encoded character can be interpreted        by <span class="hl">ISO 8859-1</span>. The difference is only the perspective.        As in <span class="hl">UTF-8</span> a single character can consist of        multiple bytes, in <span class="hl">ISO 8859-1</span> every character        is only one byte long. Hence the <span class="hl">UTF-8</span> encoded        ü will be interpreted as Ã¼.</p>
<p>You can proove this by looking at the following box: It lists the <span class="hl">UTF-8</span> encoded ü two times. On the left escaped as html entity and on the        right the original <span class="hl">UTF-8</span> encoded value. Now change the encoding for this page in your browser to <span class="hl">ISO 8859-1</span> and see what happens. The right part will change to Ã¼.</p>
<pre>ü = ü</pre>
<p>What happens if you reencode the already UTF-8 encoded string is that the  Ã and the ¼ will be interpreted as <span class="hl">ISO 8859-1</span> characters and will be transfered to their <span class="hl">UTF-8</span> equivalents, which will then look like this: ÃƒÂ¼.</p>
<h2>Using PHP&#8217;s utf8_encode and utf8_decode with Flash</h2>
<p>Now let&#8217;s get to the question about if and when to use PHP&#8217;s <span class="hl">UTF-8</span> functions (see php documentation: <a href="http://www.php.net/utf8-encode" target="_blank">utf8_encode</a> ; <a href="http://www.php.net/utf8-decode" target="_blank">utf8_decode</a>). The first thing we have learned is that if we have a string containing only        <span class="hl">ASCII</span> characters, no <span class="hl">UTF-8</span> encoding is needed as <span class="hl">ASCII</span> is a subset of <span class="hl">UTF-8</span>. The moment characters from the extended <span class="hl">ASCII</span> charset are intergrated <span class="hl">UTF-8</span> encoding has to        be done.</p>
<p>But what is with decoding from <span class="hl">UTF-8</span>. Let&#8217;s        take a closer look on PHP&#8217;s <strong>utf8_decode</strong> function. The function description in the PHP manual is as follows: &#8220;Converts a string with ISO-8859-1 characters encoded with UTF-8 to        single-byte ISO-8859-1&#8243;<br />
This means that <span class="hl">UTF-8</span> encoded data is transfered        to <span class="hl">ISO-8859-1</span>. Now you can decide if that&#8217;s really what you want.</p>
<p>The big advantage of <span class="hl">UTF-8</span> is that it can represent        characters which <span class="hl">ISO-8859-1</span> cannot. So decoding to <span class="hl">ISO-8859-1</span> simply means losing        these characters. They will be converted to a question mark by the <strong>utf8_decode</strong> function.</p>
<h3>What about Flash?</h3>
<p>As of version 6, Flash supports Unicode. Flash uses <span class="hl">Unicode</span> (if not specified differently with System.useCodepage) as standard for handling        character data. The Unicode characters are mapped with <span class="hl">UTF-8</span>. (see <a href="http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_16275" target="_blank">Macromedia        technote</a> ans <a href="http://www.macromedia.com/support/flash/languages/unicode_in_flmx/" target="_blank">supportnote</a> on Unicode support)</p>
<p>You often read in tutorials about Flash and the handling of special characters        that you should simply use <strong>utf8_encode</strong> on strings before        sending them to flash and use <strong>utf8_decode</strong> when retrieving        data from flash and everything will be fine.<br />
This is simply not true.</p>
<h3>Let&#8217;s take a deeper look on this case.</h3>
<p>Let&#8217;s assume the charset your server uses is <span class="hl">ISO-8859-1</span>. Using <strong>utf8_encode</strong> on your data before sending it to flash        is mostly a good idea namely in the case that your data is not already <span class="hl">UTF-8</span> encoded and is containing characters other than <span class="hl">ASCII</span>.        If you are sending only <span class="hl">ASCII</span> characters you        don&#8217;t need to encode the string to <span class="hl">UTF-8</span>, but        if you do so it will be no problem.</p>
<h3>What will happen if you receive data from Flash and use <strong>utf8_decode</strong>?</h3>
<p>All <span class="hl">UTF-8</span> characters will be converted to <span class="hl">ISO-8859-1</span>.        This means the ü from the example above will be converted to its <span class="hl">ISO-8859-1</span> equivalent.But what if the person sending the data e.g. through an Flash inputfield        is from Russia, Japan etc. In this case there will be no <span class="hl">ISO-8859-1</span> equivalent        for the <span class="hl">UTF-8</span> characters and the characters        get replaced by a question mark. This is apparently not the desired result.</p>
<p>The solution for this is quite simple. If you are planning a flash guestbook,        forum, chat etc. which should support all languages just keep your fingers        off the <strong>utf8_encode</strong> and <strong>utf8_decode</strong> function. Just save your received data as is to e.g. a database. The result will be        some weird signs as they are interpreted as <span class="hl">ISO-8859-1</span>.        But don&#8217;t care. When it&#8217;s time to send this data back to flash, get your        data from the database and send it as is, because it is already <span class="hl">UTF-8</span> encoded by Flash. All other data which does not originate from Flash, e.g. some text for a        button, has to be <span class="hl">UTF-8</span> encoded (again only        if it contains characters of the <span class="hl">extended ASCII</span> charset) before it is sent to Flash.</p>
<h3>What about <strong>textfields</strong> in Flash?</h3>
<p>You must not use textfields        with <strong>embedded fonts</strong>. As these textfields will only show        the characters you have embedded and you cannot embed the whole <span class="hl">Unicode</span> charset. If fonts are <strong>not embedded</strong> Flash will look on the client&#8217;s        system for the font you chose and will use this font to display the content        of the textfield. In this case the restriction is on the font&#8217;s supported        characters. To display most <span class="hl">Unicode</span> characters on Windows        systems the font <strong>Arial Unicode MS</strong> is the best choice, as        it is Windows standard and supports 51,180 characters.</p>
<p>Another possibility is using Flash&#8217;s <strong>device fonts</strong>. Flash&#8217;s        device fonts are no fonts themselves. A device font defines a general font        type. During playback of the movie, these fonts will be substituted with        an installed font that matches that type. E.g. the device font _sans will normally be mapped with Arial on Windows        systems and Helvetica on a Mac. These mapped fonts normally are standard system fonts with a good chance        to support Unicode characters. See this <a href="http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_15403" target="_blank">Macromedia        technote</a> for further information.</p>
<h2>CXS and UTF-8</h2>
<p>Now when using a CXS parser on data already <span class="hl">UTF-8</span> encoded you can use the flag <strong>NO_UTF8</strong> to prevent encoding. On the other side when retrieving data from Flash which possibly consists        of characters which are not in the <span class="hl">ISO-8859-1</span> charset use the flag <strong>NO_UTF8</strong> to prevent decoding to <span class="hl">ISO-8859-1</span>.</p>
<h2>Links</h2>
<p>Some links with additional information on the topic:</p>
<ul>
<li><a href="http://www.unicode.org/unicode/standard/WhatIsUnicode.html" target="_blank">What        is Unicode? by unicode.org</a></li>
<li>UTF-8 specification <a href="#" target="_blank">ISO        10646-1:2000 Annex D</a> and <a href="http://www.ietf.org/rfc/rfc3629.txt" target="_blank">RFC        3629</a></li>
<li><a href="http://www.columbia.edu/kermit/utf8.html" target="_blank">a good UTF-8 sample site</a></li>
<li><a href="http://www.macchiato.com/unicode/Unicode_transcriptions.html" target="_blank">unicode        tables, an UTF converter etc. are available on this site</a></li>
<li><a href="http://www.productbeta.com/tutorials/show.php?goomba=1&amp;" target="_blank">a        short and good tutorial on Flash MX &amp; Unicode</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.zehnet.de/2005/02/12/unicode-utf-8-tutorial/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
