I recently noticed that the file encoding of the pages I create in my editor are all over the place. Some are saved as ANSI, some are "UTF-8 Without BOM". I am referring to PHP, HTML, CSS, JavaScript files.
What is the best format to save my files in?
The utf8_encode() function is an inbuilt function in PHP which is used to encode an ISO-8859-1 string to UTF-8. Unicode has been developed to describe all possible characters of all languages and includes a lot of symbols with one unique number for each symbol/character.
The default source encoding used by PHP is ISO-8859-1 . Target encoding is done when PHP passes data to XML handler functions. When an XML parser is created, the target encoding is set to the same as the source encoding, but this may be changed at any point.
The advised way to go is to use UTF-8 everywhere in your web application. It includes :
A nice cheatsheet : http://developer.loftdigital.com/blog/php-utf-8-cheatsheet
Edit : Just want to add, related to your question context, that PHP don't handle file encoding in UTF-8 with BOM. Use UTF-8 without BOM and you'll be just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With