0

我想要在查询字符串中使用印度语言的编码 URL。例如

http://online3.esakal.com/newsdetails.aspx?newsid = 4741992566950155024&sectionId = 10sectionName =पुणे&newstitle =पुण

如果我在 android 的 web 视图中加载上面的 URL,我会在 WebViewClient 的 onPageFinished 回调方法中得到以下 URL。

来自 webview 客户端的编码 url:

http://online3.esakal.com/NewsDetails.aspx?NewsId=4741992566950155024&SectionId=10SectionName=%E0%A4%AA%E0%A5%81%E0%A4%A3%E0%A5%87&NewsTitle=%E0%A4% AA%E0%A5%81%E0%A4%A3%E0%A5%8D%E0%A4%AF%E0%A4%BE%E0%A4%A4%20%E0%A4%97%E0%A4% A3%E0%A4%B0%E0%A4%BE%E0%A4%AF%E0%A4%BE%E0%A4%B2%E0%A4%BE%20%E0%A4%89%E0%A4% A4%E0%A5%8D%E0%A4%B8%E0%A4%BE%E0%A4%B9%E0%A4%BE%E0%A4%A4%20%E0%A4%A8%E0%A4% BF%E0%A4%B0%E0%A5%8B%E0%A4%AA%20(%E0%A4%AB%E0%A5%8B%E0%A4%9F%E0%A5%8B%E0%A4 %AB%E0%A5%80%E0%A4%9A%E0%A4%B01)

但是,如果我使用以下代码对原始 url 进行编码,我会在编码后得到以下 url:

尝试 {

        String url1 = "http://online3.esakal.com/NewsDetails.aspx?" +
                "NewsId=4741992566950155024&SectionId=10SectionName=पुणे&NewsTitle=पुण्यात गणरायाला उत्साहात निरोप (फोटोफीचर1)";
        URL url = new URL(url1);
        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), 
                url.getPort(), url.getPath(), URLEncoder.encode(url.getQuery(), "UTF-8"), url.getRef());
        url = uri.toURL();

        String str1 = url.toString();

        }catch(Exception e) {
        System.out.println(""+e);
    }

: http://online3.esakal.com/NewsDetails.aspx?NewsId%253D4741992566950155024%2526SectionId%253D10SectionName%253D%25E0%25A4%25AA%25E0%25A5%2581%25E0%25A4%25A3%25E0%26NewsATitle%25E0%26News5%2 %253D%25E0%25A4%25AA%25E0%25A5%2581%25E0%25A4%25A3%25E0%25A5%258D%25E0%25A4%25AF%25E0%25A4%25BE%25E0%25A4%25A4+%25E0%25A4%2597 %25E0%25A4%25A3%25E0%25A4%25B0%25E0%25A4%25BE%25E0%25A4%25AF%25E0%25A4%25BE%25E0%25A4%25B2%25E0%25A4%25BE+%25E0%25A4%2589%25E0 %25A4%25A4%25E0%25A5%258D%25E0%25A4%25B8%25E0%25A4%25BE%25E0%25A4%25B9%25E0%25A4%25BE%25E0%25A4%25A4+%25E0%25A4%25A8%25E0%25A4 %25BF%25E0%25A4%25B0%25E0%25A5%258B%25E0%25A4%25AA+%2528%25E0%25A4%25AB%25E0%25A5%258B%25E0%25A4%259F%25E0%25A5%258B%25E0%25A4 %25AB%25E0%25A5%2580%25E0%25A4%259A%25E0%25A4%25B01%25291

我不明白 web-view 如何进行 url 编码?

4

0 回答 0