I am storing some french content in database but it converted to ?.
String : médiévaux, principalement pour l’anglais et le français, is converted to médiévaux, principalement pour l??anglais et le français,
I have applied utf-8 encoding to jsp page, and to the servlets as well.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
and in servlets
response.setCharacterEncoding("utf-8");
I have also tried with decoding the string
return (string != null) ? new String(string.getBytes(), UTF8_CHARSET) : null;
and then encode it.
return (string != null) ? new String(string.getBytes(UTF8_CHARSET)) : null;
code of getting from JSP and setting it in a servlet
response.setCharacterEncoding("utf-8");
String content = request.getParameter("inputFr");
if(content == null){
throw new Exception("exception");
}
content = new String(string.getBytes(), UTF8_CHARSET);
but still the question marks appearing in the above content string. Any Help is very much appreciated.
The problem is that you send parameter in the URL that is not encoded. To encode it use
URLEncoder.encode(content, "UTF-8");. You can decode it in the JSP as