The symbol � (replacement character) appears in UTF-8 documents where the character cannot be interpreted, probably because it is an ISO-8859-xx character.
If you want to work with utf-8 at all levels, you must do so by following these steps:
Your server must return the header Content-Type: text/html; charset=utf-8either generated from the PHP script itself (with header('Content-type: text/html; charset=utf-8')) or from the web server ( AddTypeor AddCharsetin the Apache configuration, for example).
PHP locales must also support UTF-8. Almost all modern Linux systems default to en_US.UTF-8or es_ES.UTF-8or equivalent. If the one configured by default is different, you must change it with setlocale(LC_ALL, 'es_ES.UTF-8'). Use locale -ato get the available list.
Your HTML must have the character set defined using the tag <meta http-equiv="Content-Type" content="text/html; charset=utf-8">in HTML4 compatibility and/or <meta charset="utf-8">using HTML5.
Your text editor must support UTF-8 so that the texts you enter in the PHP scripts are correctly encoded.
Both the user/password request form and the one that shows the result (the one that gives you problems) must meet those requirements so as not to give you any kind of problem with character sets.
Your problem could be about:
You have created a document with the correct HTML tags, the correct HTTP headers are sent, but the editor you used has created a PHP receive file with ISO encoding instead of UTF. The solution is to open the file that receives the form and look for the option in your editor to save it in UTF-8.
The headers or encoding of the source form is fine (UTF), but the page receiving the data is not. The solution is to put headers and labels at the same level to match the encoding.
Since your text seems static, programmed in the script in a fixed way, I prefer the first option.
The symbol � (replacement character) appears in UTF-8 documents where the character cannot be interpreted, probably because it is an ISO-8859-xx character.
If you want to work with utf-8 at all levels, you must do so by following these steps:
Content-Type: text/html; charset=utf-8
either generated from the PHP script itself (withheader('Content-type: text/html; charset=utf-8')
) or from the web server (AddType
orAddCharset
in the Apache configuration, for example).UTF-8
. Almost all modern Linux systems default toen_US.UTF-8
ores_ES.UTF-8
or equivalent. If the one configured by default is different, you must change it withsetlocale(LC_ALL, 'es_ES.UTF-8')
. Uselocale -a
to get the available list.<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
in HTML4 compatibility and/or<meta charset="utf-8">
using HTML5.Both the user/password request form and the one that shows the result (the one that gives you problems) must meet those requirements so as not to give you any kind of problem with character sets.
Your problem could be about:
Since your text seems static, programmed in the script in a fixed way, I prefer the first option.
you could try to use
utf8_encode()
to encode in utf8 the text extracted from the files, example:I hope this helps you