Reputation: 95
Found this simple contact form on the internet. Everything is ok, but the alert can't seem to display some characters that are specific for my language like ā ē š ž ī ļ. Here is the code of the contact form:
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Jūsu ziņa ir saņemta!');
window.location = '/';
</script>
<?php
}
Here is how the alert gets displayed.
I'll appreciate any help. Thanks.
Upvotes: 2
Views: 485
Reputation: 129109
Use Unicode escapes where ASCII won't do:
alert("J\u016bsu zi\u0146a ir sa\u0146emta!");
It's fairly simple to encode more strings yourself, too, assuming you've got Python 3:
$ python3
>>> x = "Jūsu ziņa ir saņemta!"
>>> print(x.encode('ascii', error='backslashreplace').decode('ascii'))
J\u016bsu zi\u0146a ir sa\u0146emta!
Upvotes: 4
Reputation: 1268
Consider using HTML codes for specific character in specific language
for example Ā
has the char html code ā
about all others you can find the code here.
Upvotes: 1
Reputation: 97717
Jūsu ziņa ir saņemta!
in utf-8 is Jūsu ziņa ir saņemta!
in iso-8559-1, so the browser is interpreting your utf-8 text as iso-8559-1. Try adding <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
in your head tag to fix this.
Upvotes: 1