• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Some characters not displaying properly

 
Ranch Hand
Posts: 346
10
Eclipse IDE Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 346
10
Eclipse IDE Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I use the French layout often, but this page has been created using US English layout.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 346
10
Eclipse IDE Chrome Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic