views:

195

answers:

1

Trying the following method to open an Arabic URL:

  String cmd = "cmd.exe /C start \"Open file\" \"http://ar.wikipedia.org/wiki/موسوعة\"";
  Runtime.getRuntime().exec( cmd );

Unfortunately, the URL being opened is http://ar.wikipedia.org/wiki/??????

Any thoughts on why this is or how I could prevent this?


Before you ask why I don't use java.awt.Desktop.getDesktop().open(), it's because of this Sun bug: http://bugs.sun.com/bugdatabase/view%5Fbug.do?bug%5Fid=6457572

+3  A: 

If you want this particular example to work - i.e. open an URL with UTF-8 in it, try this:


String params = URLEncoder.encode("موسوعة", "utf-8");
String cmd = "cmd.exe /C start \"Open file\" \"http://ar.wikipedia.org/wiki/" + params + "\"";
Runtime.getRuntime().exec(cmd);

Bozho
perfect, that's what was missing. thanks.
Epaga