Diff for Latin1-encoded files

I'm using both Latin1 and UTF8 encoded files in my projects. The browser showing diffs seems always to assume the UTF8 encoding, resulting in incorrectly showing non-ascii characters. Is there a way to tell SourceTree (or Git) about the encoding of a file?

Addendum: picking an encoding on a per-project basis would be sufficient rather than on a per-file basis. The reason I'm using Latin1 in some projects is that these are legal documents that I share with non-developers on Windows machines that seem to prefer it.

2 answers

1 accepted

Actually, I take it back, there is a way to do this. You can create a .gitattributes file for the folder/pattern and define the 'encoding' setting there. This should be picked up by SourceTree in the diffs too. http://schacon.github.com/git/gitattributes.html

No. There's no practical reason to be using Latin1 encoding in 2012. While you can change the encoding in git, doing it on a per-file basis is very impractical. You'll save ourself far more pain just by standardising on UTF.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

790 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you