My script is saved in uft-8 encoded file:
test.js
function sayhi(){
alert('Γειά σου!')
}
In html file (also utf-8) I got :
<html>
<head>
<script charset="utf-8" type="text/javascript" src="../js/mytest.js"></script>
</head>
<body>
...
<script type="text/javascript">
alert('Γειά!')
sayhi();
<script type="text/javascript">
</body>
</html>
The problem is that sayhi
which is supposed to print utf-8
string - prints an unreadable string as opposed to alert above it (alert('Γειά!')
) which prints the correct string.
What am I missing? How to make the sayhi
use the correct encoding.
Thanks.
PS. The page is served by glassfish app server (not sure if that matters)
Edit 1:
Also in my glassfish-web.xml I have declared
<parameter-encoding default-charset="UTF-8"/>
Anything else I could do in glasfish to serve javascript correctly?
Edit 2:
I failed to mention that I am also using struts2
and jersey
and something tells me that struts 2
is the culprit here. I am thinking that may be an implementation of some filters to change the encoding or a strust directive to ignore the path with javacript may solve the issue... will try the above later.