• Post Reply Bookmark Topic Watch Topic
  • New Topic

Some characters not displaying properly

 
Adrien Lapointe
Ranch Hand
Posts: 334
10
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a very simple JSP page where some special characters do not show up properly and the html equivalent where they do show up properly. At the moment, the jsp page is basically just html

I cannot figure out what the issue is since I have utf-8 set as the character set. The jsp source code for the section where the special characters are is as follow:



but it gets rendered as



Note that the – is replaced with –

Any thoughts as to what the issue could be?
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What locale is your keyboard? Sometimes a non-English locale may produce weird characters

For such special characters, it's better to use the &xxx; variations
 
Adrien Lapointe
Ranch Hand
Posts: 334
10
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I use the French layout often, but this page has been created using US English layout.
 
Dave Tolls
Ranch Hand
Posts: 2284
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What rendering are you talking about...on the client browser?
Another question would be, what character is that?
Do you know the UTF-8 codepoint for it?
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is relevant http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q1. Although it is from the Tomcat site, the explanation there applies to all servers.

A snippet from there:




....
Change all your JSPs to include charset name in their contentType.

For example, use <%@page contentType="text/html; charset=UTF-8" %> for the usual JSP pages and <jsp:directive.page contentType="text/html; charset=UTF-8" /> for the pages in XML syntax (aka JSP Documents).
...
 
Adrien Lapointe
Ranch Hand
Posts: 334
10
Chrome Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:What rendering are you talking about...on the client browser?
Another question would be, what character is that?
Do you know the UTF-8 codepoint for it?


It did not display properly on the client browser. The character is a long dash, but other characters such as the copyright symbol would not be displayed properly.

The link from Jaikiran helped fix the problem, which was probably just the server using the default encoding. I did put <meta charset="utf-8" /> in the head of the html, but obviously would not tell the server what the encoding of the jsp was, so adding <%@ page contentType="text/html; charset=UTF-8" %> fixed the issue.

Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!