I'm using datapicker
but the utf8 characters are displaying wrong in my html like DéCEMBRE
or AOûT
. All my files (.jsp & .js) are saved as utf-8.
$( "#datepicker" ).datepicker({
//...
monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août',
'Septembre', 'Octobre', 'Novembreé', 'Décembre'],
//...
});
Also i set this:
<head>
<meta charset="UTF-8">
<script src="${pageContext.request.contextPath}/resources/js/calendar.js" charset="UTF-8"></script>
<script src="${pageContext.request.contextPath}/resources/js/datepicker.js" charset="UTF-8"></script>
I'm using datapicker
but the utf8 characters are displaying wrong in my html like DéCEMBRE
or AOûT
. All my files (.jsp & .js) are saved as utf-8.
$( "#datepicker" ).datepicker({
//...
monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août',
'Septembre', 'Octobre', 'Novembreé', 'Décembre'],
//...
});
Also i set this:
<head>
<meta charset="UTF-8">
<script src="${pageContext.request.contextPath}/resources/js/calendar.js" charset="UTF-8"></script>
<script src="${pageContext.request.contextPath}/resources/js/datepicker.js" charset="UTF-8"></script>
Share
Improve this question
edited Nov 27, 2014 at 10:48
Hayi
asked Nov 27, 2014 at 10:20
HayiHayi
6,29630 gold badges83 silver badges154 bronze badges
3
-
1
Make sure you have:
<meta charset="utf-8">
just below<head>
– Andreas Louv Commented Nov 27, 2014 at 10:22 - yes of course i have it. – Hayi Commented Nov 27, 2014 at 10:24
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
– Hayi Commented Nov 27, 2014 at 10:25
4 Answers
Reset to default 6Try setting UTF-8 in your script tag example:
<script src="/explorer/html/js/datepicker/locales/bootstrap-datepicker.fr.js" charset="UTF-8"></script>
I'm using boostrap datepicker and all works fine.
In my opinion, the simplest possible way to get rid of this issue is to use the HTML representation of your special characters
For example for é use é
So it will be 'Férier'
See http://www.ascii.cl/htmlcodes.htm for a list of the available codes
We solved the problem and The solution was weird because after doing all the possible solution as Xavier propose
Here are different thinks to think about: international characters in Javascript in short: Meta must have UTF8, files must be saved as UTF8(important!) and your Webserver may need to have UTF8
The problem was not fixed so I make a clean..
and clean Tomcat Work Directory
in my tomcat server and I restart it. I refresh the page In chrome but I still got wrong character
So I try with Mozilla and the problem was finally solved also i open a new window in Chrome using ctrl+shift+n. This will open a new incognito window and the character display good.
So for normal chrome it works after i closed the tab and i open it again.
So i think it's a cache problem in apache tomcat
or in browsers cache so to avoid this problem you have to try all this solution ;)
I simply had to ensure that the locale file was saved as UTF-8 instead of ANSI. I didn't seem to need charset attributes on script tags or a meta tag indicating that (at least in Chrome).