0
$\begingroup$

In a text file you can write both the letter 'A' and number '65'. But obviously one of these data will be saved with different bits while the ASCII standard gives the letter 'A' the binary code for 65. Does a .txt file use some sort of container for different interpretations of binary? How does this work?

$\endgroup$
1
  • 1
    $\begingroup$ about your particular confusion between 'A' and '65', the answer is that 'A' has a value encoding of 65, but '65' (note the quotation mark! it means this is a string, and not a number!) are two letters, '6' and '5', where the letter '6' encodes into the value 54, and '5' encodes into 53. So the representation of the string 'A65' would be the three bytes [65][54][53] $\endgroup$
    – nir shahar
    Commented Oct 12, 2022 at 18:30

1 Answer 1

3
$\begingroup$

I don't understand what you mean by container. But any file, may it be a text file, image, videos, executables, etc. are stored in binary. Now the interpretation of a file is dependent on the particular program that will read it. As for text editors, it will interpret the content based on a selected character enconding. Most text editor will try to auto detect the encoding for a given file and some might have a default expected enconding.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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