GitHub: Using UTF-8 encoding for files

2019-04-19 08:04发布

Why isn't UTF-8 the default encoding for GitHub?

Does that mean that there are any drawbacks to change from the default "cp1252"?

Does it have anything to do with using GitHub across platforms between Windows and Mac OSX?

The question is asked from using GitHub, but can be asked about Git in general.

I'm mostly doing development in .NET, HTML5 and Javascript, if that matters in the subject.

1条回答
狗以群分
2楼-- · 2019-04-19 08:51

Wild guess: are you using TortoiseGit? Is that were you're seeing a default encoding set to cp1252?

If so, it's simply TortoiseGit using the default encoding of your Windows installation.

Edit: Exactly the same is true for the Git GUI

Here's a discussion from a git developer's mailing list giving an explanation:

  • Make diffs and blame default to the system (locale) encoding instead of hard-coding UTF-8.
  • Add a gui.encoding option to allow overriding it.
  • gitattributes still have the final word.

The rationale for this is Windows support:

  1. Windows people are accustomed to using legacy encodings for text files. For many of them defaulting to utf-8 will be counter-intuitive.
  2. Windows doesn't support utf-8 locales, and switching the system encoding is a real pain. Thus the option.
查看更多
登录 后发表回答