Does Ascii use binary files?

ive read about this topic and did not receive specific information on my question:

(maybe the following is wrong, but please correct me)

Each file (text / binary) saves BYTES.

byte is 8 bits, so the maximum value is 2^8-1 = 255.

these 255 codes are divided into 2groups:

0..127 : textual chars
128:..255 : special chars.

therefore, the binary contains char codes from the entire range: 0..255(ascii characters + special characters).

1) right?

2) NOw, let's say that im saves one INT in a binary file. (4 bytes on a 32-bit system)

how does the file tell progem that it reads: not 4 single unbound bytes , but int, which are is4 bytes?

+3
source share
3

char : 0..255 ( ascii + ).

, . 0 255. , . (, JPEG), - 65 "A" - , 65 .

( , " ASCII" " " - . UTF-16 . UTF-8 , .)

, : 4 , int, 4 ?

. , . JPEG, - . , , JPEG, , .

, , , , - , . , XML: , - , .. : 4- , - . .

: () :

Im Cmd shell.... . , . , 4 4 ?

, , , . , . , .

, , - , - . , ... ? , , , , ?

( , , , - XML).

+2

, , , . , , , .

, ? (.. ASCII , )?

, - , .

Windows .txt - . . , , .

, BinaryWriter BinaryReader, . , BinaryWriter StringReader?


:

using (var test = new BinaryWriter(new FileStream(@"c:\test.bin", FileMode.Create)))
{
    test.Write(10);
    test.Write("hello world");
}

using (var test = new BinaryReader(new FileStream(@"c:\test.bin", FileMode.Open)))
{
    var out1 = test.ReadInt32();
    var out2 = test.ReadString();

    Console.WriteLine("{0} {1}", out1, out2);
}

, , ? .

:

using (var test = new BinaryReader(new FileStream(@"c:\test.bin", FileMode.Open)))
{
    var out1 = test.ReadString();
    var out2 = test.ReadInt32();

    Console.WriteLine("{0} {1}", out1, out2);
}

( ). , , . . , ( - ).

+3

. , , , , . , ( , ).

, , , . , 48 65 6C 6C 6F 20 53 6F 6F 68 6A 75 6E :

  • (Hello Soohjun)
  • 12 (H, e, l, l, o, , S, o, o, H, j, u, n)
  • int, (1214606444, 1864389487, 1869113973, 110)
  • , float, unsigned int, float (72, 6.977992E22, 542338927, 4.4287998E24) ..

You choose the value of these bytes, another program will make a different interpretation of the same data, in many ways the same combination of letters has a different interpretation, say, in English and French.

PS: By the way, the goal of reverse file formats is to find the value of each byte.

+1
source

All Articles