I have an annoying problem that I am trying to figure out.
I need to support Simplified Chinese in a webapp that also supports ISO-8859-1.
I figure the best way is to make my web pages encoded in UTF-8.
The database access and display works, but I am having trouble with getting post data to come out correctly.
I am running Tomcat 4.1.24 on a RedHat Linux 7.1 box with JDK 1.4.1_01.
I have tried using the following JSP file to test the post input from a Windows 2000 Server box that allows me to input Simplified Chinese. But every encoding in the JSP file gives me garbage back.
Any ideas?
Thanks.
-- Nathan Christiansen
Tahitian Noni International
http://www.tahitiannoni.com
<<<<< Included JSP File >>>>>
<%@(protected)"
%><%@(protected).*"
%><% String strRawData = request.getParameter("data");
String strGBK = null;
String strEUC_CN = null;
String strGB18030 = null;
String strMS936 = null;
String strCp935 = null;
String strGB2312 = null;
String strMS950 = null;
String strBig5 = null;
String strBig5_HKSCS = null;
String strCp937 = null;
String strCp950 = null;
String strCp964 = null;
String strEUC_TW = null;
if (strRawData != null)
{
strGBK = new String(strRawData.getBytes("GBK"));
strEUC_CN = new String(strRawData.getBytes("EUC_CN"));
strGB18030 = new String(strRawData.getBytes("GB18030"));
strMS936 = new String(strRawData.getBytes("MS936"));
strCp935 = new String(strRawData.getBytes("Cp935"));
strGB2312 = new String(strRawData.getBytes("GB2312"));
strMS950 = new String(strRawData.getBytes("MS950"));
strBig5 = new String(strRawData.getBytes("Big5"));
strBig5_HKSCS = new String(strRawData.getBytes("Big5_HKSCS"));
strCp937 = new String(strRawData.getBytes("Cp937"));
strCp950 = new String(strRawData.getBytes("Cp950"));
strCp964 = new String(strRawData.getBytes("Cp964"));
strEUC_TW = new String(strRawData.getBytes("EUC_TW"));
}
%><html>
<head><title>Charset Test Page</title></head>
<body>
<%
if (strRawData != null)
{
%><pre>
strRawData = <%= new String(strRawData.getBytes("UTF8")) %>
strGBK = <%= new String(strGBK.getBytes("UTF8")) %>
strEUC_CN = <%= new String(strEUC_CN.getBytes("UTF8")) %>
strGB18030 = <%= new String(strGB18030.getBytes("UTF8")) %>
strMS936 = <%= new String(strMS936.getBytes("UTF8")) %>
strCp935 = <%= new String(strCp935.getBytes("UTF8")) %>
strGB2312 = <%= new String(strCp935.getBytes("UTF8")) %>
strMS950 = <%= new String(strMS950.getBytes("UTF8")) %>
strBig5 = <%= new String(strBig5.getBytes("UTF8")) %>
strBig5_HKSCS = <%= new String(strBig5_HKSCS.getBytes("UTF8")) %>
strCp937 = <%= new String(strCp937.getBytes("UTF8")) %>
strCp950 = <%= new String(strCp950.getBytes("UTF8")) %>
strCp964 = <%= new String(strCp964.getBytes("UTF8")) %>
strEUC_TW = <%= new String(strEUC_TW.getBytes("UTF8")) %>
</pre><%
}
%><form action="test.jsp" method="POST">
<input type="text" name="data">
<input type="submit">
</form>
</body>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)