Return to Snippet

Revision: 37518
at February 9, 2011 23:06 by adrianparr


Updated Code
import flash.text.TextField;

var myStr:String = "&%20<%20>%20"%20'%20£%20©%20%AE";

function htmlUnescape($str:String):String
{
	var tf:TextField = new TextField();
	tf.htmlText = unescape($str);
	return tf.text;
}

trace(myStr);
trace(htmlUnescape(myStr));

// OUTPUT
// &%20<%20>%20"%20'%20£%20©%20%AE
// & < > " ' £ © ®

// This doesn't work for a lot of the other HTML Entity Names.
// For example, &pound; and &copy; don't work.
// See here for a list of HTML Entity Names ...
// http://www.adrianparr.com/download/Special%20Characters%20Cheat%20Sheet.pdf
//
// For a full working class that supports ALL HTML Entity Names see here ...
// http://snipplr.com/view/46566/as3-encode-and-decode-html-entity-names-full-set/

Revision: 37517
at February 9, 2011 23:05 by adrianparr


Updated Code
import flash.text.TextField;

var myStr:String = "&amp;%20&lt;%20&gt;%20&quot;%20&apos;%20&#163;%20&#169;%20%AE";

function htmlUnescape($str:String):String
{
	var tf:TextField = new TextField();
	tf.htmlText = unescape($str);
	return tf.text;
}

trace(myStr);
trace(htmlUnescape(myStr));

// OUTPUT
// &amp;%20&lt;%20&gt;%20&quot;%20&apos;%20&#163;%20&#169;%20%AE
// & < > " ' £ © ®

// This doesn't work for a lot of the other HTML Entity Names.
// For example, &pound; and &copy; don't work.
// See here for a list of HTML Entity Names ...
// http://www.adrianparr.com/download/Special%20Characters%20Cheat%20Sheet.pdf
//
// For a full working class see here ...
// http://snipplr.com/view/46566/as3-encode-and-decode-html-entity-names-full-set/

Revision: 37516
at December 11, 2010 06:20 by adrianparr


Initial Code
import flash.text.TextField;

var myStr:String = "&amp;%20&lt;%20&gt;%20&quot;%20&apos;%20&#163;%20&#169;%20%AE";

function htmlUnescape($str:String):String
{
	var tf:TextField = new TextField();
	tf.htmlText = unescape($str);
	return tf.text;
}

trace(myStr);
trace(htmlUnescape(myStr));

// OUTPUT
// &amp;%20&lt;%20&gt;%20&quot;%20&apos;%20&#163;%20&#169;%20%AE
// & < > " ' £ © ®

// This doesn't work for a lot of the other HTML Entity Names.
// For example, &pound; and &copy; don't work.
// See here for a list of HTML Entity Names ...
// http://www.adrianparr.com/download/Special%20Characters%20Cheat%20Sheet.pdf

Initial URL


Initial Description


Initial Title
AS3 Unescape HTML (inc. common Entity Names - But not all)

Initial Tags
html

Initial Language
ActionScript 3