0

I've used URLLoader and URLRequest to get a file with japanese file name from server. However I got IO error that file is not existing (I double checked that file is existing on server and I can get other files with Latin name). Below is my code:

var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE, this._onFileLoaded);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this._onSecurityError);
loader.addEventListener(IOErrorEvent.IO_ERROR, this._onIOError);
var urlRequest:URLRequest = new URLRequest("http://localhost/files/メイリオ.txt");
loader.load(urlRequest);

Is there a way to get file from server with japanese file name using AS3? Any help would be appreciated greatly.

The_asMan
  • 6,352
  • 4
  • 21
  • 34
Han La
  • 1
  • have you tried to load the file in a browser first? – The_asMan Jun 19 '12 at 05:45
  • I tried, but I got this error message "HTTP Status 404 - /file/%E3%83%A1%E3%82%A4%E3%83%AA%E3%82%AA.txt The requested resource (/file/%E3%83%A1%E3%82%A4%E3%83%AA%E3%82%AA.txt) is not available." – Han La Jun 19 '12 at 10:54

1 Answers1

0

Try using UTF-8 percent-encoding.

Try using this filename instead:

 var urlRequest:URLRequest = new URLRequest("http%3A%2F%2Flocalhost%2Ffiles%2F%E3%83%A1%E3%82%A4%E3%83%AA%E3%82%AA.txt");
Jorjon
  • 4,848
  • 1
  • 39
  • 56
  • Thank you for your answer. I tried to use escape() and encodeURI(), but not work. Because I want to get file directly without any handle at server to parse or decodeURI request, so encoded URL doesn't work with URLRequest. – Han La Jun 19 '12 at 05:20
  • Ok, I don't have any other clue... Are you sure it's the same name? I mean, these Japanese kanjis can be tricky... Try copy and paste the name. Also, what hosting are you using? [IIS](http://en.wikipedia.org/wiki/Internet_Information_Services)? – Jorjon Jun 20 '12 at 19:00
  • 1
    I found the reason. I tested and run on local web server. I deployed to server, it run OK now. Thank you for your ideas, anyway. – Han La Jun 27 '12 at 14:43