For example I have a file on my disk: a.txt
I opened it in Hex mode and see no other signal character in it but plain text in UTF-8.
I am wondering how OS know it is UTF-8??
Thanks,
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The OS doesn’t know. The hex editor is probably auto-detecting it. That’s possible by looking out for the presence and absence of specific byte pairs, but it’s not 100% reliable.
There is no general flag or property in which a file’s encoding is stored. That’s why you often need to specify the encoding manually when opening a text file.
One approach to mark a UTF-8 or -16 file is the BOM but that’s not mandatory.