No more ISO charset, use UTF-8!
The Latin ISO was retired years ago, the W3C has been suggesting use of UTF8 (see RFC-3629) in all recommendations. Likewise, for Brazilian websites, the recommendation e-PING is the charset standard UTF-8...
Suit pattern: idem, UTF-8. If you check large Brazilian portals or even Brazilian portals, you will see in the HTML header that the adopted standard is UTF8 (ex. <meta http-equiv="Content-Type"../>
of the source code of UOL).
Your instruction setlocale( LC_ALL, 'pt_BR', 'pt_BR.iso-8859-1', 'pt_BR.utf-8'...)
can prioritize ISO and ignoring UTF8 - see what the manual says, "if locale is a matrix or contains additional parameters, then each element of the matrix is tried as a location until it succeeds".
I suggest only UTF-8.
A possible setlocale
, already voted, is the tip of https://stackoverflow.com/a/10927727 , but beware of confusion-Windows,
header('Content-type: text/html; charset=utf-8');
setlocale(LC_ALL, NULL); // limpa com defaults do sistema... não precisa.
// ERRADO, força Windows setlocale(LC_ALL, 'Portuguese_Brazil.1252');
setlocale(LC_ALL, 'pt_BR.utf-8'); // acho mais correto.
Adapting to your preferences, it would be something like
header('Content-type: text/html; charset=utf-8');
setlocale( LC_ALL, 'pt_BR.utf-8', 'pt_BR', 'Portuguese_Brazil');
date_default_timezone_set('Europe/Lisbon');
I personally always use the following setting:
setlocale(LC_ALL,'pt_BR.UTF8');
mb_internal_encoding('UTF8');
mb_regex_encoding('UTF8');
Your PHP scripts... are UTF8?
Another common problem is your own PHP script, which also needs to be in UTF8(!). Check with a serious and reliable editor (never Windows Notepad!), for example Sublimetext or Textpad.
Idem databases, XML files, etc. Everything needs to be the same charset, and, easy: just always configure everything with the "universal standard", which is UTF8.
"date_default_timezone_set('Europe/Lisbon')" - this Europe/Lisbon doesn’t interfere? shouldn’t it be something like America/Sao_paulo? http://php.net/manual/en/timezones.america.php
– athosbr99
I’m from Portugal, so I think this is the right way
– Miguel
ah! sometimes I forget that we have users who are not Brazilian...
– athosbr99
Dude, I’ve always had problems with ISO. Always look for start your application already with UTF-8, Voce will not have more problems with accentuation
– tiaguinhow