github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.11k stars 4.2k forks source link

Source code is recognized as Binary #3083

Closed zhenyu-zhou closed 8 years ago

zhenyu-zhou commented 8 years ago

Hello,

I have several files generated by VS2015. They are recognized as binary on github so that I couldn't follow their commit history. The file does contain Chinese in comment and when I run git diff upon it, I got sth like: ^@c^@o^@u^@t^@ ^@<^@<^@ ^@ The legal characters are separated with illegal one, which is pretty strange.

I have attached one of them. Can anyone help me to make its commit history readable?

Thanks! LLSIF_VirtualPlayerDlg.h.txt

Alhadis commented 8 years ago

The file is misencoded, probably as a result of a failed character-set conversion.

It's being detected as binary because there are null-bytes between each character.

zhenyu-zhou commented 8 years ago

@Alhadis Thank you! Then I can simply remove the null-bytes by copying and pasting. One more thing, may I ask is it possible for github to show a readable commit history for such binary files?

Alhadis commented 8 years ago

No, it isn't.

You can explicitly tell Git the file isn't binary by using a .gitattributes file:

./relative-path-to-file.txt text

However, this doesn't work on GitHub: only when running Git client-side.

zhenyu-zhou commented 8 years ago

@Alhadis Okay thank you so much!