8

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?

MrWhite
  • 43,179
  • 8
  • 60
  • 84
user1108996
  • 275
  • 2
  • 4
  • 13

4 Answers4

4

The advised way to go is to use UTF-8 everywhere in your web application. It includes :

  • File encoding
  • Database charset and encoding
  • String handling
  • HTML charset output

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.

Claaker
  • 257
  • 2
  • 9
  • Hi, Thank you! I always use UTF-8 everywhere but I never paid attention to how the files themselves were saved. – user1108996 Apr 12 '12 at 20:54
1

I vote fore UTF-8 without BOM. Note though that if you only use regular English characters, ASCII and UTF-8 files will almost always be identical! This means that your editor may read the charset as ASCII even though you saved it as UTF-8.

Emil Vikström
  • 90,431
  • 16
  • 141
  • 175
0

Unless you do a lot of CJK work, you should save your files in UTF-8 without a BOM.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

UTF-8 is what I use...

It is best for English. http://en.wikipedia.org/wiki/UTF-8

The Man
  • 1,462
  • 3
  • 23
  • 45