Encode HTML in Flex/Actionscript

2019-02-21 19:45发布

问题:

Are there any functions available to convert:

Me, Myself & I

to

Me, Myself & I

I can't find anything in the Flex documentation.

Thanks.

回答1:

Check this out. No swc's to include. Basically it's

var s:String = new XMLNode(3, "Me, Myself & I").toString();



回答2:

Here's the AS3 solution:

import flash.xml.XMLNode;
import flash.xml.XMLNodeType;

public function htmlEscape(str:String):String {
    return XML( new XMLNode( XMLNodeType.TEXT_NODE, str ) ).toXMLString();
}

Source: http://www.razorberry.com/blog/archives/2007/11/02/converting-html-entities-in-as3/



回答3:

Escape should do it:

http://livedocs.adobe.com/flex/201/langref/package.html#escape%28%29



标签: html flex