• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problems of encoding in firefox

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
CONTENT="no-cache">
</head>
<body>
<form name="form" method="post">
<%
String theString = null;
PrintWriter pw = null;
String cmntbox = "";
ServletOutputStream outStream = null;
try {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
InputStream sImage;
con = DBConnection.getConnection();
sql = SELECT statement
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
byte bytearray[] = new byte[1048576];
String newLine = System.getProperty("line.separator");
sImage = rs.getBinaryStream(1);
StringWriter writer = new StringWriter();
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
pw =response.getWriter();
IOUtils.copy(sImage, writer);
theString = writer.toString();
pw.write(theString);
pw.flush();
cmntbox = Utility.getCommentPage(id,prcs_area);
String comment = new String(cmntbox.getBytes("UTF-16LE"),"UTF-8");
pw.write(comment);
pw.flush();
pw.close();
}

Above pasted is the code.
I am getting output as
<�h�3�>�C�o�m�m�e�n�t�s�<�/�h�3�>� �<�t�a�b�l�e�>�<�t�r�
�b�g�c�o�l�o�r�=�'�#�E�7�E�7�E�F�'�>�<�t�d�>�P�o�s�t�e�d�
�O�n�:� �1�2�-�1�3�-�2�0�1�0� �1�0�:�3�8�:�2�4� �,� �B�y�:
And this output is coming only for few pages.For other pages it works fine
Any suggestions for the problematic output.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am suspecting that you problem lies here:

String comment = new String(cmntbox.getBytes("UTF-16LE"),"UTF-8");

try without it.
 
prasanna raghunath
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That part of code for comment is written since i would get junk characters if i didn't convert them like the below code.
the output without the below part code looks like this :

[edit: non-English text removed]

[quote=Vikas Aggarwal]I am suspecting that you problem lies here:

String comment = new String(cmntbox.getBytes("UTF-16LE"),"UTF-8");

try without it.[/quote]
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic