Ad

What Is The Appropriate Character Encoding For A Git Repo?

- 1 answer

Specifically what encoding to use if the repo has both code and docs? Any .md or .htm files are saved as UTF-8, but code is cp1252 (my compiler doesn't like the 3-byte BOM which Windows adds to UTF-8 files).

As seen in Git GUI tool (Edit -> Options...):

As seen in Git GUI tool

Frankly, does it even matter what setting I choose?

My system is Windows 8.1, and the system encoding is cp1252

Ad

Answer

The setting in git GUI only sets the default encoding. Real encoding should be set via .gitattributes. For example:

echo '*.html encoding=utf-8' >> .gitattributes
echo '*.c encoding=cp1252' >> .gitattributes

PS. What editor do you use that you cannot configure BOM in it? I recommend to disable BOM and use one encoding for all text files.

Ad
source: stackoverflow.com
Ad