Reputation: 122
I am developing a website that includes some text files (saved with .txt file extension).
Should they be UTF-8 (with BOM), or is ANSI (1252) O.K.? (Windows adds a 3-byte BOM when I save as UTF-8).
I would like to do whatever is considered to be best practise.
Upvotes: 1
Views: 1474
Reputation: 201798
UTF-8 is generally preferred on the web, though in the specifications, this seems to relate to HTML resources, formally speaking.
There is hardly any practical problem with windows-1252, if it is properly declared in HTTP headers sent by the server and all the data can be written using the restricted repertoire supported by that encoding.
Using UTF-8 with BOM, you practically guarantee that user agents get the encoding right. You might still have problems with your authoring tools, such as PHP. But if you create and save the resources yourself, using UTF-8 capable tools, there is hardly any objection to UTF-8.
Upvotes: 1
Reputation: 3422
Which languages your website is using?
I'm tempted to say there is no absolute best practices (well, it applies to many question). If you're in a 100% English environment and it is meant to stay that way, you don't really need to bother about encoding.
My current project is using Asian languages and European languages so ANSI was out of question. If you don't target old browsers and if your application manages UTF-8 without any problem, I suggest to directly go for UTF-8 because if you realize later that an encoding change is required, this is not fun...
For further reading, you can read the matter regarding encoding in website
Upvotes: 1