如何处理 UNICODE URL?

5 java unicode url

如果我想在 Java 中传递以下 URL:

\n\n

UNICODE 格式 URL 的屏幕截图

\n\n

...我应该用什么句柄来处理字符串。

\n\n

到目前为止,我无法处理该字符串,我所拥有的只是???字符。

\n\n

谢谢。

\n\n

2012年9月9日修改:

\n\n
package pruebas;\n\nimport java.io.UnsupportedEncodingException;\nimport java.net.URL;\nimport java.net.URLConnection;\nimport java.net.URLDecoder;\nimport java.net.URLEncoder;\nimport java.util.Vector;\n\npublic class Prueba03\n{\n    public static void main(String argumentos[])\n    {\n        Vector<String> listaURLs = new Vector<String>();\n\n        listaURLs.add("http://\xd0\xbf\xd1\x80\xd0\xb5\xd0\xb7\xd0\xb8\xd0\xb4\xd0\xb5\xd0\xbd\xd1\x82.\xd1\x80\xd1\x84/");\n        listaURLs.add("http://www.\xe4\xb8\xad\xe5\x9b\xbd\xe6\x94\xbf\xe5\xba\x9c.\xe6\x94\xbf\xe5\x8a\xa1.cn");\n        listaURLs.add("http://www.\xe5\x8e\x9f\xe4\xbe\x86\xe6\x88\x91\xe4\xb8\x8d\xe5\xb8\xa5.cn/");\n        listaURLs.add("http://\xd9\x88\xd8\xb2\xd8\xa7\xd8\xb1\xd8\xa9-\xd8\xa7\xd9\x84\xd8\xa3\xd8\xaa\xd8\xb5\xd8\xa7\xd9\x84\xd8\xa7\xd8\xaa.\xd9\x85\xd8\xb5\xd8\xb1/");\n\n        URL currentURL;\n        URLConnection currentConnection;\n        int currentSize;\n\n        for(int i=0; i<listaURLs.size(); i++)\n        {\n            try\n            {\n                System.out.println(URLDecoder.decode(listaURLs.get(i), URLEncoder.encode(listaURLs.get(i), "UTF-8")));\n            } // End of the try.\n            catch(UnsupportedEncodingException uee)\n            {\n                uee.printStackTrace();\n            } // End of the catch.\n            catch(Exception e)\n            {\n                e.printStackTrace();\n            } // End of the catch.\n\n            try\n            {\n                currentURL = new URL(listaURLs.get(i));\n                System.out.println("currentURL" + " = " + currentURL);\n\n                currentConnection = currentURL.openConnection();\n                System.out.println("currentConnection" + " = " + currentConnection);\n\n                currentSize = currentConnection.getContentLength();\n                System.out.println("currentSize" + " = " + currentSize);\n            } // End of the try.\n            catch(Exception e)\n            {\n                e.printStackTrace();\n            } // End of the catch.\n        } // End of the for.\n    } // End of the main method.\n} // End of the Prueba02 class.\n
Run Code Online (Sandbox Code Playgroud)\n

Yai*_*sky -2

不确定“解析”是什么意思 - 你打算用这些部分做什么?
据我所知,阿拉伯语和俄语都支持 UTF-8。
不确定您的数据源是什么(也许是某种 Stream?),但String有一个接受所需编码的 CTOR。
您应该能够获得一个不包含 ??? 的字符串 当涉及阿拉伯语和俄语时,如果您使用此 CTOR(带有“UTF-8”参数)