-2

I'm having a trouble with a site. I set the charset to Unicode, but it still won't work. Here there is sample code of how I set it:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    http://www.w3.org/TR/html4/loose.dtd>

<html lang="it">

    <head>
        <meta name="viewport" content="width=device-width">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" charset="iso-8859-1">
        <title>HOME</title>
    </head>

    <body>
        <h1> This are some accented letters and various symbol</h1>

             <p>è é ç ò ù § ▼ à </p>
    </body>

</html>

[1]: https://i.stack.imgur.com/csRk2.jpg

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Deanjoe
  • 15
  • 1
  • 8
  • You can simply use `` with HTML5. Care the ``must be in **first position**. – Alexis Nov 02 '16 at 10:34
  • I think you must set the encoding in your editor. If you use Windows and Notepad, you must use Unicode or UTF-8 from encoding dropdown. – Rouhollah Mazarei Nov 02 '16 at 10:35
  • @R.Mazarei , where i find it in Notepad? – Deanjoe Nov 02 '16 at 10:44
  • In the save(as) dialog, it is on the left side of Save button. – Rouhollah Mazarei Nov 02 '16 at 11:00
  • My save(as) dialog open a window where i could do: name_file : myfile | save OR save_as : choose_extension_file | cancels – Deanjoe Nov 02 '16 at 11:12
  • @Deanjoe Can you take a screenshot from save dialog? – Rouhollah Mazarei Nov 02 '16 at 11:46
  • The problem is not in my Notepad. Look at the Answer to get the new update from my code. Note: in the sample code, accentend letters and symbol works, if i put them into a div element it fail displaying char � – Deanjoe Nov 02 '16 at 11:58
  • @Deanjoe this is what I see: [link](https://i.imgsafe.org/9d91f5e69a.png). Can you take a screenshot? – Rouhollah Mazarei Nov 02 '16 at 12:18
  • 3
    There are two points to consider, if you want to serve the HTML page as UTF-8. First save the file as UTF-8, this is the job of the editor you are using. Second put the correct meta tag to the html page. You can check your page with the [W3C checker](http://validator.w3.org/i18n-checker/) and you can have a look at my small [article](http://www.martinstoeckli.ch/php/php.html#utf8) about UTF-8 for PHP (works the same with HTML). – martinstoeckli Nov 02 '16 at 12:18
  • @R.Mazarei Here my Notepad "Save(as)" dialog: [link](https://postimg.org/image/k7oqh3h75/) – Deanjoe Nov 02 '16 at 13:29
  • 2
    You are using Notepad++, you can set (or check) the encoding from Encoding menu (forget about save dialog). I think it is "Formato" in your notepad++. Consider @martinstoeckli comment. And again take a look at my screenshot, specially the page source. [Heres my screenshot](https://s13.postimg.org/5nl0vklw7/encode.png) – Rouhollah Mazarei Nov 02 '16 at 13:53
  • Thanks for comments, i solved my error. As you say i don't considered the Notepad UTF-8 encoding. By setting it right, pages show the letters and symbol. Special thanks to @martinstoeckli for the sources. – Deanjoe Nov 02 '16 at 14:59

1 Answers1

2

Add the following line within the head tag and remove your charset:

<meta charset="UTF-8">

Or replace

<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="iso-8859-1">

with

<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="utf-8">

For more information, check HTML <meta> charset Attribute

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
reza
  • 1,507
  • 2
  • 12
  • 17