answersLogoWhite

0


Best Answer

You can distinguish between binary and text files, and for the most part even identify what type of binary file, by using the "file" command. For example:

~$ file unknownfile

unknownfile: PNG image data, 155 x 155, 8-bit/color RGBA, non-interlaced

This tells you that the file is a PNG file by reading metadata and/or magic numbers in the file. When used on a text file, the command will return "ASCII text" or "Unicode text."

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

There is no distinction because text files are also binary files. Although text files do represent printable text, there are many different ways to encode plain text, whether as single byte ASCII characters or as multi-byte UNICODE. Prior to processing any plain text file, the file must first be treated as being a binary file in order to determine how the file was encoded. Even so, byte order marks and/or XML tags are optional in plain text files, so it may not be possible to determine the correct encoding method other than by examining the file's content in full, searching for certain character sequences that simply should not be present in a plain text file. If none are found it may be safe to assume the file really is plain text, but there are no guarantees.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you distinguish between a text file and a binary file?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the difference between binary file and executable file?

windows support 2 file formats 1.text file 2.binary file in a text file in windows , each line is teminated with a carriage reurn followed by a linefeed character .but when a file is read by a c prog in text mode,c library converts carriage reurn/ linefeed character both in to a single linefeed character. but in case of binary file ,the prog will see both carriage return & linefeed character


What is the difference between binary file and text file in java?

HI... When you access a file from within C or C++ you have a choice between treating the file as a binary file or as a text file. C uses the fopen(file,mode) statement to open a file and the mode identifies whether you are opening the file to read, write, or append and also whether the file is to be opened in binary or text mode. C++ opens a file by linking it to a stream so you don't specify whether the file is to be opened in binary or text mode on the open statement. Instead the method that you use to read and/or write to the file determines which mode you are using. If you use the operator to write to the file then the file will be accessed in text mode. If instead you use the put() and get() or read()and write() functions then the file will be accessed in binary mode. So what exactly is the difference between text and binary modes? Well the difference is that text files contain lines (or records) of text and each of these has an end-of-line marker automatically appended to the end of it whenever you indicate that you have reached the end of a line. There is an end of line at the end of the text written with the C fwrite() function or in C++ when you


What is the difference between binary file and text file?

The difference is that text files may only contain printable character codes, either from the ASCII character set or the UNICODE character set. That is, letters, digits, punctuation, space, tab and other symbols, including line feed or carriage return/line feed pairs. Non-printable characters, such as the null character '\0' (or '\0\0' in UNICODE), are not permitted in plain-text files, however UNICODE files permit a 16-bit endian marker at the start of the file to denote the byte order of the wide characters that follow. Text files can be displayed in any plain-text editor or word processor (as unformatted text). The entire text can also be extracted as a string (memory permitting), or as a stream of printable characters in a string buffer. Binary files, on the other hand, cannot be interpreted as plain-text (although they may contain plain text elements). Binary files may contain any combination of bytes, and require special handling in order to be interpreted correctly. The exact meaning of the order of the bytes is entirely dependent upon the program that created the binary files in the first place.


What is mean by text and binary files used in c?

A text file is a file containing human readable characters organized into records (lines) that are separated by the new-line character. The run-time library parses on this basis, and converts carriage-return/line-feed sequences to and from the new-line character as needed. (In a Windows/DOS environment.)A binary file is a file containing any characters. There is no file based delimiting - all record distinctions are made by the program. (The exception to this is in the IBM (and other?) family of MainFrame computers where logical record sizes are declared in the DCB, and the file is not processed in stream mode.)


How do you convert text into binary in vb or c sharp code?

C# EXAMPLEString text="My sample data";System.Text.ASCIIEncoding encode=new System.Text.ASCIIEncoding();//convert to binary and store in a byte[]byte[] binaryArray=encode.GetBytes(text);

Related questions

Which type of file occupies less space text file or binary file?

binary file


What are the modes of accessing a file?

"text" and "binary"


Is php a binary file?

No, PHP is text file with .php extension.


What is an explanation of the file modes briefly?

Two file modes are "text" and "binary". Text is used for human readable data, such as a C source file, or a notepad text file. Binary is used for computer readable data, such as an executable object file. Two other file modes are "sequential" and "random". Sequential is used when the file is accessed serially, from the beginning to the end, and can be used for both text and binary files. Random is used when the file is accessed non-serially, often jumping around from place to place. An example of random is a database file.


What are the different types of files and how End Of File of a full represented by a pointer?

There are two file types in C++ namely, text file and binary file. In text file EOF or end of file is represented by an end of file character having ASCII 26. In binary files EOF or end of file is represented by NULL in the file pointer


What is the difference between binary file and executable file?

windows support 2 file formats 1.text file 2.binary file in a text file in windows , each line is teminated with a carriage reurn followed by a linefeed character .but when a file is read by a c prog in text mode,c library converts carriage reurn/ linefeed character both in to a single linefeed character. but in case of binary file ,the prog will see both carriage return & linefeed character


What is difference between text and binary files?

A binary file is a computer file which may contain any type of data, encoded in binary form for computer storage and processing purposes; for example, computer document files containing formatted text. Many binary file formats contain parts that can be interpreted as text; binary files that contain only textual data - without, for example, any formatting information - are called plain text files. In many cases, plain text files are considered to be different from binary files because binary files are made up of more than just plain text. When downloading, a completely functional program without any installer is also often called program binary, or binaries (as opposed to the source code).A text file (sometimes spelled "textfile") is a generic description of a kind of computer file in a computer file system.[1] At this generic level of description, there are two kinds of computer files: 1) text files; and 2) binary files.[2] This broad two-level distinction is widely recognized and applied in computing, even though it can be misleading,and subject to differing interpretation


What is the difference between binary file and text file in java?

HI... When you access a file from within C or C++ you have a choice between treating the file as a binary file or as a text file. C uses the fopen(file,mode) statement to open a file and the mode identifies whether you are opening the file to read, write, or append and also whether the file is to be opened in binary or text mode. C++ opens a file by linking it to a stream so you don't specify whether the file is to be opened in binary or text mode on the open statement. Instead the method that you use to read and/or write to the file determines which mode you are using. If you use the operator to write to the file then the file will be accessed in text mode. If instead you use the put() and get() or read()and write() functions then the file will be accessed in binary mode. So what exactly is the difference between text and binary modes? Well the difference is that text files contain lines (or records) of text and each of these has an end-of-line marker automatically appended to the end of it whenever you indicate that you have reached the end of a line. There is an end of line at the end of the text written with the C fwrite() function or in C++ when you


What is a bdat file?

A bdat file is a binary data file. It contains data that is not in the form of text. The data is encoded for the purposes of computer storage and processing.


How do you convert binary code to text code and text to binary?

You can are ASCII-tabellen. For converting binary to text


What is data interrogation?

A bdat file is a binary data file. It contains data that is not in the form of text. The data is encoded for the purposes of computer storage and processing.


Is there a way to convert a binary dll file to text so the dll file can be read and understood?

If you have access to the symbols and a debugger, then yes. However, without a symbol file for the binary, you can only extract limited information from the binary. You might try Spy++(SpyXX.exe), Dependency Walker (depends.exe), and/or a hex editor. A symbol file will have the same name as the binary DLL, or EXE and a file extension of .pdb (e.g. ntdll.dll, ntdll.pdb / ntoskrnl.exe, ntoskrnl.pdb)