JSP Charset Encoding For Vietnamese Not Displaying Properly
We already have our web application displaying properly in Simplified chinese开发者_Go百科 (GB18030) and english (Cp1252).
Right now, I am trying to make some changes to have the web application display in Vietnamese. I have tried 'UTF-8' but to no avail.
Below is how I am currently doing it
<%@ page contentType="text/html;charset=UTF-8"%>
The characters in the database are displayed correctly though when I use Oracle SQLDeveloper to do a SELECT * FROM TABLENAME
.
We are currently using
- Java 1.4
- Oracle DB 10g
- Oracle Internet Appliaction Server 10g (OC4J)
Specifying the contentType
alone is not sufficient. This only sets the response header. But you need to specify the response encoding as well so that the server knows which encoding to use to send the bytes to the client. The following line does that:
<%@ page pageEncoding="UTF-8" %>
As a bonus, it also implicitly sets the right charset in the JSP default content type. So the above line alone ought to be sufficient. You don't need to add a contentType
, it already defaults to text/html
anyway and any charset specified by pageEncoding
will implicitly be added.
See also
- Unicode - How to get the characters right?
You may need to include a meta tag to help the browsers render the page with correct encoding.
Java Programming with Vietnamese
精彩评论