Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Some characters not displaying properly

 
Ranch Hand
Posts: 342
10
Eclipse IDE Chrome 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?
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • 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: 342
10
Eclipse IDE Chrome 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.
 
Rancher
Posts: 4623
47
  • 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?
 
Sheriff
Posts: 10445
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: 342
10
Eclipse IDE Chrome 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!
 
Screaming fools! It's nothing more than a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic