Question

I have a web form which submits the comment to a predefined mail when the userfills it and clicks submit button, this is done using my Send.php file which includes all the codes needed to submit the comment with correct content and encoded with utf-8. everything works fine, however, after this procedure I included in the php file the JS code which popups the Alert windows, saying that the mail is sent, and after clicking OK button it redirects to the homepage.

this is a code:

 echo '<script type="text/javascript">; 
       alert("კომენტარი გაიგზავნა წარმატებით, გმადლობთ"); 
       </script>';  

 echo '<script type="text/javascript">
       window.location = "http://g-projects.net78.net/index.html";
       </script>'

However, because the alert text is in foreign language I get various unreadable symbols. I need to use utf-8 encoding, but how can I integrate it with this code? note that this code is called in PHP file.

Was it helpful?

Solution

Tell your text editor to edit your source file in utf-8.

Note that "კომენტარი გაიგზავნა წარმატებით, გმადლობთ" is a literal, so it is embedded in your php source file.

For example, in Notepad++ set: Encoding | Encode UTF-8.

(It already seems you have your html thinking it is outputting UTF-8, I hope.)

OTHER TIPS

The system font for displaying message boxes is Segoe UI or Tahoma, by default, on Windows systems and Deja-Vu Sans or simply "Sans" on Linux systems. These fonts do not have the codes or the characters necessary to support the display of Indic text. In order to display text in that language your system's default UI font needs to have those characters encoded.

Also, just an aside: UTF-8 documents can be preambled, which means the byte-order-mark is given which tells the text processor to explicitly scan for a specific encoding. For UTF-8 three bytes EF BB BF signify text encoding. Do NOT use the preamble when saving PHP files. If you read the Unicode spec carefully, UTF-8 is designed not to be used with a preamble. But if you must add it, add it as an 'echo' from the PHP script before any other output, but do not start the PHP script file that way. (Just in case you run across this in your Unicode travels)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top