I'm not sure how proper a solution that would be -- there are a lot more html 
entities than just those and I don't think writing a replace for each character 
makes much sense.

I was initially under the impression that if I used the htmlText property, a 
string like "something & something" would auto-magically be converted to 
"something & something". If this isn't the case, is there a property or 
component in Flex which I'm overlooking that would automatically take care of 
this?

I suppose the main problem is with the text example I presented: "This is an 
item > This is another item > In a breadcrumb trail". I suppose using htmlText 
would not work because the '>' characters would be taken as closing tags? Maybe 
I can just write a function to replace '<' and '>'. (?)

Do you or any others have other suggestions or comments on what a good approach 
would be?

--- In flexcoders@yahoogroups.com, "Tracy Spratt" <tr...@...> wrote:
>
> 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("&amp;").join("&"); 
> 
>       s=s.split("&quot;").join("\"");
> 
>       s=s.split("&apos;").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: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of s_grollins
> Sent: Friday, January 08, 2010 9:42 PM
> To: flexcoders@yahoogroups.com
> 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