commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wong Ka Ho Matthew" <>
Subject [HttpClient] Sending Big5 to PHP
Date Wed, 11 Dec 2002 09:20:09 GMT

 i want to use the HttpClient to send a Big5 string to a php.

 e.g., i want to send the string "\u738B". this string contains
 only one char, if it's in Big5, it would be coded as 0xA4FD.
 (Big5 uses 2 bytes to represent a Chinese character, pls visit for reference)

 the querystring should look like: message=%A4%FD

 the problem is, i dunno how to make the querystring = %A4%FD.

 it should be quite simple, right? but i really have no idea...

 --- cut ---

  String    message = "\u738b";
  GetMethod get     = new GetMethod();

  try {
          Charset        big5Charset         =
          CharsetEncoder big5CharsetEncoder  = big5Charset.newEncoder();
          ByteBuffer     bbuf                =

          // what i should do here?
          // message = new String(bbuf.array(), "ISO-8859-1");

  } catch (Exception e) {

  NameValuePair nv[] = {new NameValuePair("message", message)};


  System.out.println("Query String: " + get.getQueryString());

 --- cut ---

 i have try to use a for loop to print the bbuf:

  byte[] b = bbuf.array();

  for (int i=0; i<b.length; i++) {
   System.out.println("-> " + Integer.toHexString(new

 and i got:

  -> ffffffa4
  -> fffffffd

 seems it's very close to what i wanna have... but, is it should
 be a4 and fd, instead of ffffffa4 and fffffffd?


 thanks in advance.


View raw message