我正在使用MediaWiki API來更新一些實驗性機器人的頁面。 該機器人使用Java Apache HTTP客戶端庫更新頁面。MediaWiki API和編碼
(...)
PostMethod postMethod = new PostMethod("http://mymediawikiinstallation/w/api.php");
postMethod.addParameter("action","edit");
postMethod.addParameter("title",page.replace(' ', '_'));
postMethod.addParameter("summary","trying to fix this accent problem");
postMethod.addParameter("text",content);
postMethod.addParameter("basetimestamp",basetimestamp);
postMethod.addParameter("starttimestamp",starttimestamp);
postMethod.addParameter("token",token);
postMethod.addParameter("notminor","");
postMethod.addParameter("format","xml");
int status = httpClient.executeMethod(postMethod);
(...)
但'content'字符串包含一些重音。 System.out.prinln(content)
看起來不錯,但wiki中突出顯示的字符看起來很糟糕。例如。 'Val rie'而不是'Valérie'。
我該如何解決這個問題?
嗨Roderic :-) 謝謝,但我不認爲這是問題所在。 'addParameters'方法在發送POST查詢時已經轉換了數據。可能是解決方案在這裏:http://tinyurl.com/lyxv8c。我明天再查。 – Pierre 2009-07-16 18:10:23