Link to home
Start Free TrialLog in
Avatar of darmcqueen
darmcqueen

asked on

special characters - html to flash

I need flash to display special characters originating from an xml file.

I have written a test app and put it into the code section.

In that code I am replacing the ® with \u00AE, but it only works for the String variable not the XML variable.

I need answer to one of two questions.

1) Is there a way to get flash to recognize the html special character and convert it to unicode.

2) Code to convert   ® to \u00AE in the xml variable.

Thank you


<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
	
	<fx:Script>
		<![CDATA[
			private var myRecords:XML =
				<records>
					<record>
					<crop>Carrot</crop>
					<product>Bravo 500 &reg;</product>
					<pestType>disease</pestType>

					</record>

					<record>
					<crop>Carrot</crop>
					<product>Dithane  F-45 &reg;</product>
					<pestType>disease</pestType>
					</record>
				</records>
			
			private var myPattern:RegExp=/&reg;/g;
			private var myString:String = "<product>Bravo 500 &reg;</product>";
			
			protected function myButton_clickHandler(event:MouseEvent):void
			{
				lbl_test.text=myRecords;
				lbl_test2.text = myRecords.replace(myPattern,"\u00AE");
				lbl_test3.text = myString.replace(myPattern,"\u00AE");
			}
			
		]]>
	</fx:Script>
	
	<s:Label id="lbl_test" x="73" y="139"   width="183" fontSize="16"/>
	<s:Label id="lbl_test2" x="278" y="139"   width="176" fontSize="16"/>
	<s:Label  id="lbl_test3" x="478" y="138"   width="166" fontSize="16"/>
	
	<s:Button id="myButton" click="myButton_clickHandler(event)" x="307" y="74" label="Click Here"/>
	
</s:Application>

Open in new window

Avatar of ChristoferDutz
ChristoferDutz
Flag of Germany image

ASKER CERTIFIED SOLUTION
Avatar of ActionScript_Helper
ActionScript_Helper
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial