I’m writing a web server in java, and when the browser sends a string (with GET or POST) with accented characters (for example à è ì ò ù) the server receives strange symbols.
I think I should use UTF-8 encoding, but I don’t know how.
Can you suggest to me a solution? (it’s ok both client/server side)
Thank you in advice!
[EDIT]
I’m using InputStreamReader on the web server. I did a test sending “àèìòù” and sniffing the http packet with wireshark:
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3\r\n
…
text=%E8%E0%EC%F2%F9
You need to read the input stream from the socket using an
InputStreamReaderwhich is constructed with"UTF-8"as 2nd argument. But if the client specified acharsetin theContent-Typerequest header, then you should use that instead.