I need to add the charset="utf-8" at the end of the script tags to get the translation to another language done.
I don know where all I should add the tags. Any rules are followed. Please let me know where to add the charset. Do i need to add at the end of "ApplicationLoader.js" or only after the jquery plugins. Any suggestion please.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Web App</title>
<link href="css/jquery/jquery.ui.all.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.custom.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/jquery.depends.js" charset="utf-8"></script>
<script type="text/javascript" src="myemployeelist.js" ></script>
Update:
I will make it more easy for you to understand my situation in details and am not a more stuff guy am a newbie under training now.As far as I understood I will explain my problems to you.
- I created a webapplication project in Eclipse, in which I created a class for JDBC connection to MySQL.
- I have a class in serverside which gets the users profile value from my webapp textbox and saves in DB.
- I am using jQuery plugin for doing translation from English to Arabic.
- I have an HTML page in which as stated in the above part of question I have the tags in which I added the charset="utf-8" to specify unicode.
- I am using dwr to get the values in js and send it to server side.
- I changed my computer input language to Arabic and my Mozilla firefox locale to Arabic.
I am able to enter the English values in mysql and I am able to retrieve it but when I enter a Arabic value it's not getting saved. The JDBC error is
java.sql.SQLException: Incorrect string value: '\xD8\xB3\xD9\x84\xD8\xA8...'
I dont know how to configure my server Jetty 6 LANG
variable to utf-8
. Any suggestion please. Thanks.
In this way:
It is usually enough to declare the main document's encoding once, either through a
content-type
header (See @BalusC's answer for an in-depth explanation) or, if that is not available, the Meta tag.If you use the Meta tag, make sure it is in the first line of the
head
section.There should be no need to specify the character set explicitly for the script files.
Of course, all the content you deal with needs to be UTF-8 encoded as well for this to work. It's not enough to just slap the content-type meta tag in front. (But you are probably aware of that.)
If a
Content-Type
header is present in the HTTP response headers, then this will override the meta headers. Very often, this header is already by default supplied by the webserver and more than often the charset is absent (which would assume client's default charset which is often ISO-8859-1). In other words, the meta headers are generally only interpreted whenever the resources are opened locally (not by HTTP). Big chance that this is the reason that your meta headers apparently didn't work when served over HTTP.You can use Firebug or Fiddler2 to determine the HTTP response headers. Below is a Firebug screen:
You can configure the general setting for HTTP response headers at webserver level. You can also configure it on a request basis at programming language level. Since it's unclear what webserver / programming language you're using, I can't go in detail about how to configure it accordingly.
Update: as per the problem symptoms, which is the following typical MySQL exception:
The byte sequence
D8 B3 D9 84 D8 A8
is a valid UTF-8 sequence which represents those charactersسلب
(U+0633, U+0644 and U+0628). So the HTTP part is fine. You mentioned that you were using Jetty 6 as servletcontainer. The later builds of Jetty 6 already support UTF-8 out of the box.However, the problem is in the DB part. This exception indicates that the charset the DB/table is been instructed to use doesn't support this byte sequence. This can happen when the DB/table isn't been instructed to use UTF-8.
To fix the DB part, issue those MySQL commands:
And for future DB/tables, use
CHARACTER SET utf8 COLLATE utf8_general_ci
inCREATE
statement as well.