Index: java/org/apache/commons/httpclient/HttpMethodBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.165 diff -u -r1.165 HttpMethodBase.java --- java/org/apache/commons/httpclient/HttpMethodBase.java 13 Jul 2003 13:54:50 -0000 1.165 +++ java/org/apache/commons/httpclient/HttpMethodBase.java 13 Jul 2003 21:48:51 -0000 @@ -497,7 +497,7 @@ */ public void setQueryString(NameValuePair[] params) { LOG.trace("enter HttpMethodBase.setQueryString(NameValuePair[])"); - queryString = formUrlEncode(params, HttpConstants.HTTP_ELEMENT_CHARSET); + queryString = formUrlEncode(params, "UTF-8"); } /** Index: test/org/apache/commons/httpclient/TestMethodCharEncoding.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethodCharEncoding.java,v retrieving revision 1.2 diff -u -r1.2 TestMethodCharEncoding.java --- test/org/apache/commons/httpclient/TestMethodCharEncoding.java 19 Jun 2003 20:52:07 -0000 1.2 +++ test/org/apache/commons/httpclient/TestMethodCharEncoding.java 13 Jul 2003 21:48:53 -0000 @@ -240,6 +240,34 @@ } + public void testQueryParams() throws IOException { + + GetMethod get = new GetMethod("/"); + + String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); + String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE); + + get.setQueryString(new NameValuePair[] { + new NameValuePair("ru", ru_msg), + new NameValuePair("ch", ch_msg) + }); + + Map params = new HashMap(); + StringTokenizer tokenizer = new StringTokenizer( + get.getQueryString(), "&"); + while (tokenizer.hasMoreTokens()) { + String s = tokenizer.nextToken(); + int i = s.indexOf('='); + assertTrue("Invalid url-encoded parameters", i != -1); + String name = s.substring(0, i).trim(); + String value = s.substring(i + 1, s.length()).trim(); + value = URIUtil.decode(value, CHARSET_UTF8); + params.put(name, value); + } + assertEquals(ru_msg, params.get("ru")); + assertEquals(ch_msg, params.get("ch")); + } + public void testUrlEncodedRequestBody() throws IOException { PostMethod httppost = new PostMethod("/");