<?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>dom111.co.uk &#187; unicode</title>
	<atom:link href="http://www.dom111.co.uk/blog/tag/unicode/feed" rel="self" type="application/rss+xml" />
	<link>http://www.dom111.co.uk/blog</link>
	<description>Move along. Nothing to see here.</description>
	<lastBuildDate>Wed, 26 Oct 2011 16:37:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>XML Entities in PHP</title>
		<link>http://www.dom111.co.uk/blog/coding/xml-entities-in-php/224</link>
		<comments>http://www.dom111.co.uk/blog/coding/xml-entities-in-php/224#comments</comments>
		<pubDate>Mon, 15 Feb 2010 20:34:35 +0000</pubDate>
		<dc:creator>dom111</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xmlentities]]></category>
		<category><![CDATA[xml_entitiy_decode]]></category>

		<guid isPermaLink="false">http://www.dom111.co.uk/blog/?p=224</guid>
		<description><![CDATA[Because htmlentities() doesn&#8217;t even come close. This small file contains 4 functions (2 of which are taken from the PHP manual, credit given!) which will allow you to encode and decode entities from ASCII/unicode strings in either decimal or hexadecimal format for use in valid XML documents. The xml_entity_decode() function accepts an optional second parameter [...]]]></description>
			<content:encoded><![CDATA[<p>Because <code lang="php">htmlentities()</code> doesn&#8217;t even come close.</p>
<p>This small file contains 4 functions (2 of which are taken from the PHP manual, credit given!) which will allow you to encode and decode entities from ASCII/unicode strings in either decimal or hexadecimal format for use in valid XML documents.</p>
<p>The <code lang="php">xml_entity_decode()</code> function accepts an optional second parameter to allow non-standard XML entities (that may have been specified in your schema) in the format:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
  <span style="color: #666666; font-style: italic;">// 'entity' =&gt; 'char'</span>
  <span style="color: #0000ff;">'amp'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'lt'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;'</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'gt'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&gt;'</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'apos'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'\''</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'quot'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&quot;'</span>
<span style="color: #009900;">&#41;</span></pre></div></div>

<p>Example usage:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'funcs.xmlentities.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;strong&gt;This&lt;/strong&gt; should be safe, but don\'t assume!&lt;br/&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'&lt;Field&gt;'</span><span style="color: #339933;">.</span>xmlentities<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/Field&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// outputs: &lt;Field&gt;&amp;lt;strong&amp;gt;This&amp;lt;/strong&amp;gt; should be safe, but don&amp;apos;t assume!&amp;lt;br/&amp;gt;&lt;/Field&gt;</span></pre></div></div>

<p>You can <a href="/files/xmlentities/funcs.xmlentities.tar.gz">get the script here</a>, or there&#8217;s <a href="/files/xmlentities/">a demo here too</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dom111.co.uk/blog/coding/xml-entities-in-php/224/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

