I'm making Android version of some hebrew website that use WikiEngine but when I try to get some data via it's API using hebrew title names I got wrong answer. Like if I try to get this URL

http://www.some-web-site.co.il/w/he/api.php?action=query&prop=revisions&rvprop=content&format=xml&titles="HEBREW_TITLE"

I got response from API that title is missing. However if I pass string like this

Blockquote %D7%A1%D7%99%D7%95%D7%A2_%D7%91%D7%A8%D7%9B%D7%99%D7%A9%D7%AA_%D7%9E%D7%9B%D7%A9%D7%99%D7%A8%D7%99_%D7%94%D7%9C%D7%99%D7%9B%D7%94

I got rigth response. This string I got when I copy-paste url from browser. So my question hot can I transfer hebrew topic name to string with this format using Java.

Thanks

有帮助吗?

解决方案

Try

 String title = "THE_HEBREW_TITLE";
 String encodedTitle = URLEncoder.encode(title , "UTF-8");

and use encodedTitle to compose the URL you are using to query the web service.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top