Normal environment: Windows2000 Professional Simplified Chinese version
Server environment: Linux BSD 2.4.26
Running system variable: LANG: zh_cn, lc_all: Air
The problem of a character set, tortured me for a long time, finally found the reason, send it to everyone, don't be so painful.
This is a particularly simple example. We have a word "Acer" in httprequest, which is special, and the deployment is "?". This word exists in GBK and does not exist in GB2312 characters.
Servlet is dealt with:
chinesename = UploadRequest.getParameter ("cname");
Very standard usage, tested normal in this unit environment and put it on the server to the board garbled.
There are two reasons why it forms:
1. The character set on the server is GB2312 and this word is not supported.
2, RESIN's HTTPRequest implementation is different from other servers.
Most servers' request streams are implemented by the "ISO8895-1" character set, and the standard correct processing method is:
chinesename = UploadRequest.getParameter ("cname");
chinesename = stringutil.iso2gbk (chinesename);
However, in RESIN, since the HttpRequest.getParameter object returns to the local default-encoded string, the server is GB2312, resulting in garbled, and Windows Chinese is GBK, so normal.
This is summarized from the phenomenon. It is not very familiar with the situation of RESIn, I don't know if my resin version is too old or understanding, but only needs to start the environment variables, lang, lc_all under Linux, LAN, LAN, LC_ALL ( LANG = zh_cn; lc_all = zh_cn.gbk; export lang lc_all settings, you can solve the problem.
If Which one knows more detailed and accurate information about Resin's character set processing, please be sure to comrade, not very grateful.