I am working on a French client, so I need to deal with accented characters. But I face great difficulties, I hope that the solution will be simple and that someone can point to me.
String: La Forêt pour Témoin
Converts to:La For? pour T?oin
Note the missing character after the accented character - t , following ê and m , following é .
I tried using StringEscapeUtils, which successfully deleted some characters, like ă . I also created my own escape function, which gives the same results ( ă will work, ê will not).
private String escapeChars(String string) {
char[] chars = string.toCharArray();
String result = "";
for (int i = 0; i < chars.length; i++) {
int c = chars[i];
result += "&#" + c + ";";
}
return result;
}
The project works in eclipse using the App Engine plugin, I can not narrow down whether the problem is caused by Java, App Engine or SQLite.
Any help is appreciated.
EDIT: I found that the string is incorrect when simply displaying the request parameter from the form. (i.e. request.getParameter ("string") already has malformed content).
I tried the meta tag suggested by Daniel without success. I think you are on the right track, but the header data of the html document follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
When accented characters are hardcoded in the JSP, they are displayed as intended.
EDIT: I also added <?xml version="1.0" encoding="UTF-8"?>to the very top of the page.
. , , . , .
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
RESOLVED: , UTF-8, java. ISO-8859-1 request.setCharacterEncoding( "ISO-8859-1" ).