There are two cases, which i confused about:

  1. If newly created file contains only latin symbols, then file -i will show us-ascii.
  2. If newly created file contains only latin and cyrillic symbols, then file -i will show utf-8

I tested this behavior with several tools for creating files within local copy of git repository: intellij idea, nano, echo etc.

However, when i push this files to remote repository, participants on Windows OS determines this files as UTF-8.

  • 2
    us-ascii is a subset of utf-8. So this may not be so strange at all... – FedonKadifeli May 15 '19 at 16:41

So, since there is no BOM generated during file creation - there is no way to distinguish ASCII and UTF-8. So in terms of correct prediction of file encoding - it is better to answer ASCII, than UTF-8 (if both contains only latin characters), since UTF-8 involves more char-codes.

Therefore file -i doing all the best.

Thanks fedonkadifeli for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.