Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

unescape

Posted on 2011-10-01
5
Medium Priority
?
347 Views
Last Modified: 2012-05-12
Hi, in Flash I am using google translate to take some text, translate it and then put it back in a text box in a chosen language. I have a list of languages to choose etc and it works fine except i end up with things like u0026quot (in the trace) being returned and then using unescape() seems to help but results in uuot still being displayed. The key part of the code is at the bottom of the following.

Any suggestions welcome.
Tom
on (release) {

	var lorem_lv:LoadVars = new LoadVars();
	txtLang.text = "Current language code is: " + lstLang.getSelectedItem().data;
	strLang = lstLang.getSelectedItem().data;
	btnReset._visible = true
	
	if (strLang == null) {
		strLang = "en";
		txtLang.text = lstLang.getSelectedItem().data;
	}

	lorem_lv.onData = function(src:String):Void  {
		clip(src);
		trace(src);
	}

	strSource = escape(txtContent.text);
	//strSource = txtContent.text;
	lorem_lv.load("http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" + strSource + "&langpair=en%7C" + strLang);

	function clip(str:String):Void {
		find_me = "translatedText";
		trace("Found "+str.indexOf(find_me));
		str = str.substr(str.indexOf(find_me)+17, str.length);
		str = str.substr(0, str.indexOf("},")-1);
		txtContent.htmlText = unescape(str);
	}

}

Open in new window

0
Comment
Question by:tomdenton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:dgofman
ID: 36897057
Can you use AS3?
0
 

Author Comment

by:tomdenton
ID: 36897109
If I have to yes, but is it possible in 1 or 2 do you think?
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36897128
Yes it's possible the reason why I like AS3 I will use a JSON class. But it's fine I can use as2 as well.
0
 
LVL 4

Accepted Solution

by:
ute_arbeit earned 2000 total points
ID: 36897250
Hi,

the \u0026 is the unicode character code for the ampersand. You have to replace it like so in your line 27:

str = unescape(str);
find_me = "\\u0026";
pos = str.indexOf(find_me);
while (pos >= 0) {
    str = str.substr (0, pos) + "&" + str.substr(pos + find_me.length, str.length);
    pos = str.indexOf(find_me);
}
txtContent.htmlText = str;

Open in new window


Cheers
0
 

Author Closing Comment

by:tomdenton
ID: 36897787
Great, thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question