echo random text > text_file Saves text_file in text format with ASCII encoding. To check the encoding, I do
chardetect text_file which tells me that the file is ASCII encoded. Now I have a jpg format file and I do the same
chardetect my_image_file but it doesnt't recognize any encoding in that jpg file.
I read these two answers (first and second) about what is the difference between file format and file encoding and understood that file encoding (ASCII, UTF-8, etc) is done for data representation to users (because computers can't understand English) and also integrity checks sometimes (Base64) while file formats are just representation of how data is presented to the application for parsing (HTML, JSON, etc) and that media and some other files (JPEG, MP4, DOC, PDF) are stored in binary format.
Questions
- Is my understanding correcy? If so,do binary format files (PDF,MP4,JPEG) do not have any encoding?
- If encoding for binary files (media/other) exist, how to detect it using terminal.
- How to detect what format a file is using (JSON, HTML, Plain Text, PDF, GIF, JPEG, etc) because
chardetectseems to only tell information about text encoding