You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Sunny L. S. Chan" <su...@deliriumctouch.com> on 2002/09/20 10:20:17 UTC

Strange Behaviour with Character Encoding with tomcat 4.0.3 & 4.1.10

Hi all,

I have a working multiple languges website which is running on tomcat 4.0.3.
(i.e. ISO-8859-1 (English) / Big5 (trad CHinese) / Simp Chinese / Japanese / French / Thai)

I manage the CharacterSet Encoding by  using the method response.setContentType() for all the languages;

When I port the web-app to tomcat 4.1.10, the JSP Big5 Strings are jumbled up in Content type "text/html;charset=Big5", 

i.e. String sTitle = "¼s¼½´CÅé"; (Big5 CHinese)

    it returns strings like "???v????" 

However in tomcat 4.0.3 environment, it can output text properly 


I later changed the coding to CONTENT_TYPE to "text/html;charset=ISO-8859-1" and it returned the Big5 text as ISO Encoding. 

I have to change the encoding manually (big5)- the language autoselection was not working in IE (internet explorer - it is default to ISO-8859-1)

I have set <Meta> tags to try to change the language selection but the problem still exist

For various reasons I cannot use UTF-8 as the display output (older broswers cannot render some text properly)

How to make IE auto language selection working / Any correct model is manage this behaviour ?


Currently I use this approach to manage my website's (tomcat 4.0.3) response output encoding :

<% //Main.jsp 

//0 = English, 1= Trad Chinese etc
int iLangID = request.getParameter("lang"); 
String  CONTENT_TYPE ="text/html;charset=ISO-8859-1";

switch (iLangID){
   case 1: //Big5
    CONTENT_TYPE ="text/html;charset=big5";
   break;
   case 2: // GB2312
    CONTENT_TYPE ="text/html;charset=gb2312";
   break;
   default: //Case 0 / others - English
    CONTENT_TYPE ="text/html;charset=ISO-8859-1";
   break;
}

response.setContentType(CONTENT_TYPE);

%>

My Current Environment:
Trad. Chinese Win2K Professional 
jdk 1.4.0
tomcat 4.1.10 



Any Help/Insight  is greatly Appreciated!
Thanks in Advance !

Sunny ~