So I understand that the data is not html, but just has some html encoded
entities in it correct?

 

You can manually convert the data yourself.  Regular expressions are
probably a better way to go, but I do not use them enough to be comfortable
with them, and use a function like this:

    public static function htmlDecode(s:String):String

    { 

      s=s.split("&").join("&"); 

      s=s.split(""").join("\"");

      s=s.split("'").join("'"); 

      s=s.split("/&lt;").join("</");

      s=s.split("&lt;").join("<"); 

      s=s.split("/&gt;").join("/>");

      s=s.split("&gt;").join(">"); 

      return s;

    }

 

The replace() function might be better as well.

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: [email protected] [mailto:[email protected]] On
Behalf Of s_grollins
Sent: Friday, January 08, 2010 9:42 PM
To: [email protected]
Subject: [SPAM] [flexcoders] Properly display html entities in datagrid

 

  

Hello everyone,

I've recently come across a problem at work where in much of the data we're
getting is showing up in the data-grid as:

<b>The tags show<b> and the &quot; quotes &quot; aren't converted!

This is a problem and I'd like to be able to display this correctly:

The tags show and the " quotes " aren't converted!

We don't necessarily have too much control over the data, so I'm not
entirely sure how/why the items are coming up like this when some items come
up with characters like < > in them. For instance: "This is an item > This
is another item > In a breadcrumb trail". This shows up correctly. I'm not
sure what exactly should be done. But again since we don't have
control/access to the data, it cannot be changed or substituted or converted
to other formats. I thought of using htmlText but that doesn't work if I
have data like the "breadcrumb string" above because it interprets the '<'
characters as opening tags and doesn't render the entire data:

[Bindable]
private var testString:String = "&lt;b&gt;6&lt;b&gt;  &quot;seven&quot;";

<mx:Text text="{testString}" /> <!-- displays testString unchanged -->
<mx:Text htmlText="{testString}" /> <!-- displays: <b>6</b> -->

Any suggestions would definitely be appreciated, I'm sure I'm probably not
the only person that's come across this :( But basically we just need all
characters like: &lt; to be converted to '<' and &amp; to be '&' meanwhile
data that was encoded properly, data that has '<' and '&' showing up
correctly should be left the same.

Thanks in advance for any help :)



Reply via email to