4

I have a php file which when displays data shows strange characters, but when I change encoding from tools in chrome to iso-8859-1 the strange characters are displayed correctly, the strange characters are actually Portuguese alphabets. please tell how can we set by default the encoding to iso-8859-1.

1 Answer 1

12
header('Content-Type: text/html; charset=iso-8859-1');

You should ideally use utf-8. If it doesn't work automatically, that means it's improperly encoded on the database and you should convert it to utf-8.

Sign up to request clarification or add additional context in comments.

2 Comments

Even though both are not state of the art nowadays, I would recommend to always use iso-8859-15 if utf-8 is not an option, as iso-8859-1 does not include the symbol.
9 times out of 10 if someone hits this page it's due to legacy IBM DB2 databases, and good luck convincing the IBM i (AS/400) sysadmin to switch if they haven't already... It was true at the time of this question, and is still true today.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.