<?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>encoding &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/tag/encoding/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Mon, 21 Jun 2010 10:27:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>encoding &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>AMFPHP issue referencing ByteArray</title>
		<link>https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/</link>
					<comments>https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Fri, 11 Jul 2008 17:08:49 +0000</pubDate>
				<category><![CDATA[amfphp]]></category>
		<category><![CDATA[amf3]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[bytearray]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[netconnection]]></category>
		<category><![CDATA[objectencoding]]></category>
		<category><![CDATA[patch]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=258</guid>

					<description><![CDATA[Recently I made some test in AMFPHP sending an retrieving ByteArray to be stored in a mysql blob field. But suddenly I encounter a problem when I was trying to return an array of ByteArrays and I could not find out the reason flash continued to show me this error: The php file which was &#8230; <a href="https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/" class="more-link">Continue reading <span class="screen-reader-text">AMFPHP issue referencing ByteArray</span></a>]]></description>
										<content:encoded><![CDATA[<p>Recently I made some test in AMFPHP sending an retrieving ByteArray to be stored in a mysql blob field.</p>
<p>But suddenly I encounter a problem when I was trying to return an array of ByteArrays and I could not find out the reason flash continued to show me this error:</p>
<p><a href="https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog.png"><img decoding="async" class="alignnone size-medium wp-image-1117" title="error_dialog" src="https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog-300x126.png" alt="" width="300" height="126" srcset="https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog-300x126.png 300w, https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog.png 658w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>The php file which was generating this error was:<br />
<code lang="php"><br />
class Service<br />
{<br />
public function getArray( )<br />
{<br />
$GLOBALS['amfphp']['encoding'] = 'amf3';<br />
$a = new ByteArray("\x00\x10this is a string");<br />
$b = new ByteArray("\x00\x16this is another string");<br />
$c = $a;<br />
return array( $a, $b, $c );<br />
}<br />
}<br />
</code><br />
While the Actionscript test class was:<br />
<code><br />
package<br />
{<br />
    import flash.display.Sprite;<br />
    import flash.net.NetConnection;<br />
    import flash.net.ObjectEncoding;<br />
    import flash.net.Responder;<br />
    import flash.utils.ByteArray;</p>
<p>    public class test extends Sprite<br />
    {<br />
        private var nc: NetConnection;<br />
        private var rsp: Responder;</p>
<p>        public function test()<br />
        {<br />
            rsp = new Responder( onResult, null );<br />
            nc = new NetConnection();<br />
            nc.objectEncoding = ObjectEncoding.AMF3;<br />
            nc.connect( "http://localhost/amfphp/trunk/gateway.php" );<br />
            nc.call( "test.bytearray.Service.getArray", rsp );<br />
        }</p>
<p>        private function onResult( e: * ): void<br />
        {<br />
            if ( e is Array )<br />
            {<br />
                for each ( var b: ByteArray in( e as Array ) )<br />
                {<br />
                    trace( 'reading bytearray...' );<br />
                    b.position = 0;<br />
                    trace( b.readUTF() );<br />
                }<br />
            }<br />
        }<br />
    }<br />
}</p>
<p></code><br />
After some investigation I found that the error was into the AMFSerializer.php file in the writeAmf3ByteArray method which doesn&#8217;t reference correctly the bytearray objects.</p>
<p>Thus I made a little modification and after that I succeeded to retrieve correctly the bytearray list ( with the 3rd element as reference of the first one ).</p>
<p>Here you can <a title="bytearray.patch" href="https://blog.sephiroth.it/wp-content/uploads/2008/07/bytearray_patch.zip">download the patch file</a>, if you want to test the modification ( at your own risk 🙂 ). The patch has been created using the last svn version of amfphp and you can apply the patch with the following command:<br />
<code>patch -p0 -i bytearray.patch</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>Charset handling proposal in AMFPHP</title>
		<link>https://blog.sephiroth.it/2005/01/28/charset-handling-proposal-in-amfphp/</link>
					<comments>https://blog.sephiroth.it/2005/01/28/charset-handling-proposal-in-amfphp/#respond</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Sat, 29 Jan 2005 01:13:20 +0000</pubDate>
				<category><![CDATA[amfphp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[charset]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[iconv]]></category>
		<category><![CDATA[mbstring]]></category>
		<category><![CDATA[utf8]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=57</guid>

					<description><![CDATA[amfphp charset handling problem and proposal<br />
]]></description>
										<content:encoded><![CDATA[<p><span style="font-weight: bold;">Patrick Mineault</span> makes a proposal for the charset handling in <a href="http://www.amfphp.org">AMFPHP</a></p>
<div style="border: 1px dotted #cccccc; margin: 10px 15px; padding: 5px; background-color: #fdf8e5; font-style: italic;"><em>[..] that should put an end to problems with Unicode and native character set handling between PHP and Flash, a problem that has palgued AMFPHP for a long time</em></div>
<p>To use charset handling in the new CVS version, you will need to call the setCharsetHandler function from your gateway.php file, like this:</p>
<pre>$gateway-&gt;setCharsetHandler("iconv", "latin1", "latin1");</pre>
<p>Detail for setCharsetHandler method: setCharsetHandler(string <span style="font-weight: bold;">mode</span>, string <span style="font-weight: bold;">phpCharset</span>, string <span style="font-weight: bold;">sqlCharset</span>)  The mode can be: 1. none (don’t do anything) 2. <a href="http://www.php.net/iconv">iconv</a> (uses the iconv libray for reencoding) 3. <a href="http://www.php.net/mbstring">mbstring</a> (uses the mbstring library for reencoding) 4. <a href="http://www.php.net/recode">recode</a> (uses the recode library for reencoding) 5. <a href="http://www.php.net/utf8_decode">utf8_decode</a> (uses the XML function utf8_decode and encode for reencoding &#8211; ISO-8859-1 only)   I haven&#8217;t tested it already, but I&#8217;m sure this is a great step toward a solution of the charset problem!</p>
<p><a href="http://www.amfphp.org/wiki/doku.php?id=charset_issue">http://www.amfphp.org/wiki/doku.php?id=charset_issue</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2005/01/28/charset-handling-proposal-in-amfphp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
