Hacker
Hacker

Reputation: 7906

Solutions to solve the encoding issue in this code

Please see the code below

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Test</title>
    </head>
    <body>
        <div>
            ¿Hola cómo está?
        </div>
    </body>
</html>

In this code, i want to print the characters properly as given in the file. 1 solution is to save the file in UTF-8 format. Is there any other way of doing it?

Upvotes: 1

Views: 353

Answers (2)

craig1231
craig1231

Reputation: 3877

Use HTML symbols such as £ for example.

http://www.ascii.cl/htmlcodes.htm

Upvotes: 1

EFraim
EFraim

Reputation: 13058

Saving the file as UTF-8 is insufficient. You should also signal the HTTP client (browser) that it's a UTF-8 document. This can be done in two ways:

  1. By forcing the server to send appropriate headers - this usually means you must have the ability to at least somewhat alter the server's configuration.
  2. Insert <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> into <head> element.

To your original question, the encoding of the PHP file can be different - you'll just have to re-encode the string from the local encoding to UTF-8 before you send it.

Upvotes: 3

Related Questions