Hi,
I don't have that book, so I am not sure if there is a new version. But I
think you can try one of the constructors in the String class.
String value = req.getParameter("param");
String valueInUnicode = new String(value.getBytes("Cp1255"), "UTF8");
-Yan
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: April 20, 2004 05:10
To: [EMAIL PROTECTED]
Subject: Getting a request in a non English character
Hi,
In an attempt to solve a problem of getting a request in a non English
character, and to convert it to Unicode,
I use a similar code , (BTW , taken from O'Reilly's "Java Servlet
programing" First edition)
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
try {
//set encoding of request and responce
req.setCharacterEncoding("Cp1255"); //for hebrew windows
res.setCharacterEncoding("Cp1255");
res.setContentType("Text/html; Cp1255");
String value = req.getParameter("param");
// Now convert it from an array of bytes to an array of characters.
// Here we bother to read only the first line.
BufferedReader reader = new BufferedReader(
new InputStreamReader(new StringBufferInputStream(value), "Cp1255"));
String valueInUnicode = reader.readLine();
}catch (Exception e) {
e.printStackTrace();
}
}
}
this works fine , the only problem is that StringBufferInputStream is
deprecated .
is there any other alternative for that ?
Thanks in advance
Yair
Yair Fine
Golden-Channels
03 9272791
052 921250
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]