Here is the code I'm using to test, and it round trips your test data fine
in Firefox and Camino:
root.attach("/zhform", new Restlet(getContext()){
public void handle(Request request, Response response){
response.setEntity("<html><body><form method='post'
action='zhproc'>"
+"city: <input type='text' size='40'
name='test1'/><br/>"
+"street <input type='text' size='40'
name='test2'/><br/>"
+"<input type='submit'/>"
+"</form></body></html>",MediaType.TEXT_HTML);
response.getEntity().setCharacterSet(CharacterSet.valueOf
("GBK"));
}
});
root.attach("/zhproc", new Restlet(getContext()){
public void handle(Request request, Response response){
CharacterSet csin = request.getEntity().getCharacterSet();
if(csin!=null)
System.out.println(">>> Incoming character set is
"+csin.getName());
else
System.out.println(">>> No incoming character set
detected");
// Force to the charset we are actually receiving. If I set
this *wrong* I get
// gibberish
request.getEntity().setCharacterSet(CharacterSet.valueOf
("GBK"));
System.out.println(">>> Character set reset to
"+request.getEntity().getCharacterSet().getName());
Form f = new Form(request.getEntity());
response.setEntity("<html><body>"
+"city: "+f.getFirstValue("test1")+"<br/>"
+"street: "+f.getFirstValue("test2")+"<br/>"
+"</body></html>",MediaType.TEXT_HTML);
// I can set any output encoding and it appears to render OK
response.getEntity().setCharacterSet(CharacterSet.valueOf
("GBK"));
}
});
So I put your test data into the form at /zhform, and it spits back readable
and fine on /zhproc ... I tried it on Camino and Safari with no trouble. Do
you know what I might be missing in order to reproduce the issue you are
seeing?
- Rob