The problem may be related to both the file encoding and some error in the output of your PHP.
Start by changing/checking the file encoding by opening it in your IDE, changing the option to encoding (or Portuguese coding), for UTF-8. Below are the step by step two editors that I believe are the most used by current professionals in the market and dev. beginners:
if you use the Sublime text you can change going into:
File -> reopen with enconding -> UTF-8 (English)
File -> reopen with encoding -> UTF-8 (English)
if you use the Notepad:
Encoding -> Convert to UTF-8 (English)
Encoding -> Convert to UTF-8 (English)
For other IDE’s you can consult the documentation of the same.
After done the above step, check if in PHP, you are using exactly header('Content-Type: text/html; charset=utf-8');
.
Also check using a debug (such as the Dev Tools of Google) if the output of your code is exactly this: <meta charset="UTF-8">
, without any loving character. Some time ago I read a text about this code that contains the charset need to be among the first 512kb of the document to avoid some bugs in some browsers. Unfortunately I could not find the link for you to take a look and I also believe that the problem related to this should already be solved, however, just to ensure that recommendation between the 1st and 3rd line of your file, I usually put right after the <meta http-equiv="X-UA-Compatible" content="IE=Edge">
being in the first line after the opening of the <head>
.
Well, if after all this your problem persists, it can also be a GOOD (byte-order mark) being related to ASCII, usually caused by copies by copy and Paste also known as CTRL+V and CTRL+C, I talked about this in that reply. Simply put, to resolve you can open the file in a basic editor (for example the windows text editor) that does not interpret Unicode or one that interprets but is able to display non-ASCII characters and delete the problem code snippet by writing the same.
Finally, it may also be related to connection Mysql, if used, according to that answer user’s Jpsy in the OS. You can solve by assigning PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
on the PDO constructor call.
Post the code of the page with problem, but can be in the configuration of the server or even the browser.
– gustavox
I am testing localhost. The problem is the same with all browsers. inside <head> usage: <meta charset="utf-8">
– Developer1903
PHP? If you use
header('content-type: text/html; charset=utf-8');
– William Okano
PHP yes. I already use as mentioned above.
– Developer1903
Probably your code editor is in another encoding, or your DB.
– Bacco
You did not mention PHP in the question. If you are using a database, it is also "relevant" to mention. And this question about charset depends on many parameters. The problem may have N causes.
– Daniel Omine