How can I prevent Flash URLRequest from escaping URLs?

I am loading some XML from a servlet from my Flex application as follows:

_loader = new URLLoader(); _loader.load(new URLRequest(_servletURL+"?do=load&id="+_id)); 

As you can imagine, _servletURL is something like http://foo.bar/path/to/servlet

In some cases, this URL contains accented characters (long story). I am unescaped string to a URLRequest , but it seems that flash is escaping from it and invoking a hidden URL, which is invalid. Ideas?

+4
source share
3 answers

My friend Louis realized this:

You must use encodeURI encodes UTF8URL http://livedocs.adobe.com/flex/3/langref/package.html#encodeURI ()

but not unescape since it is not ASCII bound, see http://livedocs.adobe.com/flex/3/langref/package.html#unescape ()

I think this is where we get% E9 in the URL instead of the expected% C3% A9.

http://www.w3schools.com/TAGS/ref_urlencode.asp

+5
source

I'm not sure if this will be different, but this is a cleaner way to achieve the same URLRequest:

 var request:URLRequest = new URLRequest(_servletURL) request.method = URLRequestMethod.GET; var reqData:Object = new Object(); reqData.do = "load"; reqData.id = _id; request.data = reqData; _loader = new URLLoader(request); 
+4
source

From liveocs: http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequest.html

Creates a URLRequest object. If System.useCodePage is true, the request is encoded using the system code page, not Unicode. If System.useCodePage is false, the request is encoded using Unicode, and not on the system code page.

There is additional information on this page: http://livedocs.adobe.com/flex/3/html/help.html?content=18_Client_System_Environment_3.html

but basically you just need to add this to the function that will run before the URLRequest (I would probably put it in the creationComplete event)

System.useCodePage = false ;

0
source

Source: https://habr.com/ru/post/1276684/


All Articles