Check if file data is binary

when I write the number in a binary file, it will not be displayed. but in the case of a character this happens. What for? how would you check if a file containing a character is binary?

+3
source share
3 answers

This is due to how you interpret what is in the file. Everything in the file is binary, the integer character, etc.

When you do TYPE in the console on a file (or in CAT or any other OS), the contents of the file are interpreted as default text, because the TYPE programmer decided to write it like this.

When you write a program to read data from a file, you decide how to interpret the data you read.

, , , .

+4

, , () , .

, , , , , .

, , , () :

  • ,
  • , ASCII
  • - , .
  • 2 3 , (ASCII, UTF-x ..).
  • , .

?

+1

, , . , , - , - ascii 0-9, -, . ascii ( , ascii), , .

:

int(1) = 1 

int('A') = 65

See how they differ from the compiler?

+1
source

Source: https://habr.com/ru/post/1742372/


All Articles