2015-06-15 62 views
1

我在這裏面臨一種奇怪的情況。用瀏覽器代碼替換一些特殊字符

我解析通過JSON的圖像鏈接,獲取網址:

http://developersatwork.com/projects/g4/tools/wp-content/uploads/2015/05/Belbin’s-Team-Roles-100x100.jpg 

每當我粘貼在瀏覽器中,然後將圖像顯示,但每當我將其粘貼到記事本,然後將以下網址是顯示達:

http://developersatwork.com/projects/g4/tools/wp-content/uploads/2015/05/Belbin%E2%80%99s-Team-Roles-100x100.jpg 

正如你可以撇號被%E2%80%99和JSON無法檢測 撇號,因此它拋出異常代替:

06-15 14:01:16.955: W/System.err(10146): java.io.FileNotFoundException: http://developersatwork.com/projects/g4/tools/wp-content/uploads/2015/05/Belbin’s-Team-Roles-100x100.jpg 

我該如何將這些特殊字符替換爲相應的代碼,以便Json能夠檢測到它們?

我試圖UTF-8編碼和解碼,但是它不是working.Please給一般化的解決方案,但不是爲特定的字符。

還有一句:

http://www.tools4management.dreamhosters.com/wp-content/uploads/2015/06/The-POSITIVE-Model-of-Coaching-–-An-8-step-Outline-to-Motivate-Goal-Accomplishment-100x100.jpg 

但是,當我從瀏覽器的鏈接粘貼到記事本中它顯示:

http://www.tools4management.dreamhosters.com/wp-content/uploads/2015/06/The-POSITIVE-Model-of-Coaching-%E2%80%93-An-8-step-Outline-to-Motivate-Goal-Accomplishment-100x100.jpg 

SOLUTION

唯一的解決方法是使用一個Webview而不是ImageVie W上。

回答

3

你需要解碼的網址。

url = java.net.URLDecoder.decode(url, "UTF-8"); 
+0

我想這before.Not工作 – kgandroid