Reputation: 39030
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: https://bugs.java.com/bugdatabase/view_bug?bug_id=6457572
Upvotes: 2
Views: 2248
Reputation: 597164
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);
Upvotes: 4