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 2005/03/02 15:13:58 UTC

DO NOT REPLY [Bug 33809] New: - UTF-16 Encoding does not work for response

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

http://issues.apache.org/bugzilla/show_bug.cgi?id=33809

           Summary: UTF-16 Encoding  does not work for response
           Product: Tomcat 4
           Version: 4.0.4 Final
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: Servlet & JSP API
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: anuj1104@yahoo.com


Tomcat 4.0.4 does not work properly with UTF-16LE Encoding .  My data is in
UTF-16LE encoding and the byte are sent back using reqsponse.getWriter() stream. 
See the code below  :-
****************************************************************************
<%
response.setContentType("text/plain; charset=utf-16le"); 
response.setHeader("Content-Disposition","attachment; filename=\"test.csv\"");
java.io.PrintWriter out1 = response.getWriter();
//Add  Multibyte data  82A7
String strData = "test"+"\u82A7";
strData = new String(strData.getBytes("UTF-16LE"),"UTF-16LE");
//Write BOM and UTF-16 encoded String
out1.write("\uFEFF"+strData);
out1.flush();
out1.close();
%>
****************************************************************************

This code does not work properly on tomcat4, The jsp does not show the pop up
Open/Save Dialog as desired .  
If ,  response.setContentType("text/plain; charset=utf-16le"); this is changed to
response.setContentType("text/plain; charset=utf-8");
the the Open/Save Dialog  comes up.  But it saves the File in UTF-8 encoding. 
This is Wrong , since File contains data in  UTF-16LE ( required for CSVs that
has Multibyte data and microsoft Supports UTF-16LE by default for Excel) 

If I run the above Code in Tomcat5, it  works fine. The file "test.csv" is saved
in Unicode Encoding and gets opened properly in MsExcel. 

Did i miss something for tomcat4 ? 
Is it a Bug with  tomcat4

Thanks,
Anuj

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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