You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2003/10/31 23:17:31 UTC

DO NOT REPLY [Bug 24308] New: - for charset="UTF8" request.getParameter("i1").getBytes() return non UTF8 bytes

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24308>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24308

for charset="UTF8" request.getParameter("i1").getBytes() return non UTF8 bytes

           Summary: for charset="UTF8" request.getParameter("i1").getBytes()
                    return non UTF8 bytes
           Product: Tomcat 4
           Version: 4.1.29
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Unknown
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: thilowill@gmx.net


Example JSP:
<%@ page contentType="text/html;charset=UTF8" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF8" />

<FORM>
	<INPUT TYPE="text" NAME="i1" />
</FORM>

<%    	
	String i1=request.getParameter("i1");
	if(i1 ==null)return;
	byte[] bytes=i1.getBytes();
%>
Value of String(bytes,"UTF8"):<br>
<%=new String(bytes,"UTF8") %>
<br>

Values of the byte array:<br>

<% 
    for(int i=0; i<bytes.length; i++){
%>
	<%= bytes[i]%> <br>
<%  } %>


When I enter some characters above 127 e.g. the character 
"Ä" or a cyrillic character then

request.getParameter("i1").getBytes()

returns a byte array that does not contain the 
correct UTF( encoding for these characters.
This is easily seen by looking at the output generated by
<%=new String(bytes,"UTF8") %>

By the way the length of the byte array is ok so for "Ä" it has length two
and for chinese characters it hastb length 3.

Same Problem already in Tomcat 4.1.27

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org