JSP displaying single and double quotes as a character

I have a JSP page receiving data, and when single or double quotes are in the text, they are displayed as this character.

JSP Code:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>General</title>
    </head>
    <body>
        <h1> <%= order.getDescription %> </h1> 
    </body>
</html>

Example: an order description should look like this:

"20 - 4" x 6 "widgets"

but I get it

"20 - 4 x 6 widgets"

NOTE. I cannot make changes to the database.

[EDIT]

I used commons-lang-2.4.jar to avoid characters, and these are the main characters that give me problems:

  • & # 145 → '
  • & # 146 → '
  • & # 147 → "
  • & # 148 → "
  • & # 150 → -

I'm sure other characters in some format will give me problems, however I just replaced the characters with a temporary fix, and I'm currently testing the suggestions below.

[ ]

, , , . bean , .

description = StringEscapeUtils.escapeHtml(description);

description = description.replaceAll("&#145;", "&quot;");
description = description.replaceAll("&#146;", "&quot;");
description = description.replaceAll("&#147;", "&quot;");
description = description.replaceAll("&#148;", "&quot;");
description = description.replaceAll("&#150;", "-");

description = StringEscapeUtils.unescapeHtml(description);
+5
4

, , ... , ?

, , "" , .

+1

U + 0094, . , , ISO-8859-1 , Windows 1252 (). , 0x80-0x9F . Windows cp1252 , , , , : double-close-quote (", U + 201D RIGHT DOUBLE MOTOR).

, -, , - ISO-8859-1, cp1252 . , , , .

, , , CP1252, , String ISO-8859-1 - , , . Unicode , , CP1252 ISO-8859-1. , , ? .

, , , , , ISO- 8859-1 , CP1252. , .

[Side-issue: close-double-quote - . "(Unicode U + 2033 DOUBLE PRIME) , , " ".

+8

0094 is a curly double quote. Write a method to replace it with a straight double-quote, or the HTML entity for curly double-quote: &rdquo; or , which displays like: 4" x 6”

0

0094, , . , , 0094 - , , . , CANCEL, , .

, Latin-1 Unicode block. , ( ) .

, , , , .

The output filter will basically replace Unicode characters, which give you problems with better options.

0
source

All Articles