Special and accented characters

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" ).

+3
4

EDIT: , , . (.. request.getParameter( "" ) ).

:

  • GET, UTF-8 URI . , , , Tomcat: URIEncoding HTTP- /conf/server.xml UTF-8.

  • POST, , servletcontainer UTF-8 . request.setCharacterEncoding("UTF-8") .

  • , , UTF-8. , , , Eclipse: "" > "" > " " > " " UTF-8.

. :

+6

, , , .

  • Unicode ( ), , SQLite .
  • , , .
  • , , " ", (, UTF-8)

, , , , . , SQLite , ...

+1

, HTML-, , . Content-Type: text/html; charset=UTF-8 HTTP head:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

, XHTML:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

meta .

, , HTML , W3C.

See also: Frequently asked questions: strange characters and question marks appear instead of accented characters

+1
source

Is it possible that the string is in tact, but are you trying to print these characters using local localization?

0
source

Source: https://habr.com/ru/post/1751269/


All Articles