473,513 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Text files

Is difference between interpretation of \n only difference ?

Jul 19 '07 #1
14 2022
On Thursday 19 Jul 2007 11:33 pm, Kenneth Brody
<ke******@spamcop.netwrote in message
<46***************@spamcop.net>:
ra****@op.pl wrote:
>>
Is difference between interpretation of \n only difference ?

Difference in what?

Oh, I see... You put some critical information in the subject
and failed to include it in the body of your message. The
relevent information is "text files".

So, I assume your question is "are there any differences between
text mode and binary mode, other than '\n' interpretation?"
I rather think the OP meant to ask whether there were any other
differences apart from end-of-line interpretation, between different
text files on different systems.

To the OP:

As far as text files of different system's are concerned, they are
meant to be portable, and to a Standard C program, there should be
no difference between text files created by it and those created by
other implementations.

Under the hood, there may well be many more differences than just the
end-of-line one, but they're all supposed to be well hidden by the
operating system and the C library.
Jul 19 '07 #2

<ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googlegro ups.com...
Is difference between interpretation of \n only difference ?
The behavior of fseek.
Jul 19 '07 #3

<ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googlegro ups.com...
Is difference between interpretation of \n only difference ?
No. Text files often have a control Z as end of file marker. However on most
systems the text and binary formats are in fact identical.#
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jul 19 '07 #4
On Friday 20 Jul 2007 1:29 am, Malcolm McLean
<re*******@btinternet.comwrote in message
<jL******************************@bt.com>:
>
<ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googlegro ups.com...
>>
Is difference between interpretation of \n only difference ?

No. Text files often have a control Z as end of file marker.
[ ... ]

AFAIK, this is rare among most modern systems.
Jul 19 '07 #5
Malcolm McLean wrote, On 19/07/07 20:59:
>
<ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googlegro ups.com...
>Is difference between interpretation of \n only difference ?
No. Text files often have a control Z as end of file marker. However on
most systems the text and binary formats are in fact identical.#
So you think most systems are not DOS/Windows/VMS/MacOS-9/whatever? I'm
sure at least one other OS I know has a different format for text files
to binary files, but I'll stick to the ones where I know there are
differences. Also, remember that Windows probably includes WinCE and its
successors which are used in some PDAs and mobile phones.
--
Flash Gordon
Jul 19 '07 #6
Flash Gordon <sp**@flash-gordon.me.ukwrites:
Malcolm McLean wrote, On 19/07/07 20:59:
><ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googlegr oups.com...
>>Is difference between interpretation of \n only difference ?
No. Text files often have a control Z as end of file marker. However
on most systems the text and binary formats are in fact identical.#

So you think most systems are not DOS/Windows/VMS/MacOS-9/whatever?
I'm sure at least one other OS I know has a different format for text
files to binary files, but I'll stick to the ones where I know there
are differences. Also, remember that Windows probably includes WinCE
and its successors which are used in some PDAs and mobile phones.
What exactly does "binary format" mean? On many (most?) systems,
there's no such thing as a "binary format" -- or rather, there's a
practically infinite number of such formats, at least potentially.

A text file is (usually) just a special case of a binary file, with
some structure imposed on it.

Now it would make sense to ask what translations are performed when
access a file in text mode as opposed to binary mode, but I'm not sure
whether that's what the OP asked.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 19 '07 #7
"Malcolm McLean" <re*******@btinternet.comwrites:
<ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googlegro ups.com...
>Is difference between interpretation of \n only difference ?
No. Text files often have a control Z as end of file marker. However
on most systems the text and binary formats are in fact identical.#
What on earth is "binary format"?

And what are "most systems"?

Jul 20 '07 #8
Richard wrote:
"Malcolm McLean" <re*******@btinternet.comwrites:
><ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googlegr oups.com...
>>Is difference between interpretation of \n only difference ?
No. Text files often have a control Z as end of file marker.
However on most systems the text and binary formats are in
fact identical.#

What on earth is "binary format"?
A catch-all name, I presume, for all human-unreadable
information.

Jul 20 '07 #9
santosh said:
Richard wrote:
>"Malcolm McLean" <re*******@btinternet.comwrites:
>><ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googleg roups.com...
Is difference between interpretation of \n only difference ?

No. Text files often have a control Z as end of file marker.
However on most systems the text and binary formats are in
fact identical.#

What on earth is "binary format"?

A catch-all name, I presume, for all human-unreadable
information.
Binary doesn't necessarily mean human-unreadable. Those amongst us who
have written programs in binary, as I have, will almost certainly agree
that, whilst reading binary isn't necessarily top of their Ten Fun
Things To Do Today list, it is nevertheless possible.

In any case, if you're right /and/ Malcolm is right, then text files are
unreadable too, on most systems. Is that your contention?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 20 '07 #10
"Malcolm McLean" wrote:
<ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googlegro ups.com...
>Is difference between interpretation of \n only difference ?
No. Text files often have a control Z as end of file marker. However on
most systems the text and binary formats are in fact identical.#
The most common form of text files use ASCII code, and there is no character
called 'control Z' in ASCII. Furthermore, I don't know of any compiler for
desktop computers that expects EOF to be encoded in the data, EOF is a
*condition* detected by the OS. One can signal EOF from a keyboard by
pressing the key combination ctrl + 'z', usually written as ^Z, on a DOS
based machine. I think that is what is referred to above, but it has
nothing to do with files. Files are an *external* representation of a data
set, a keyboard is not an external representation.
Jul 20 '07 #11
osmium wrote:
"Malcolm McLean" wrote:
><ra****@op.plwrote in message
news:11**********************@m3g2000hsh.googlegr oups.com...
>>Is difference between interpretation of \n only difference ?
No. Text files often have a control Z as end of file marker.
However on most systems the text and binary formats are in
fact identical.#

The most common form of text files use ASCII code, and there is
no character
called 'control Z' in ASCII.
Furthermore, I don't know of any
compiler for desktop computers that expects EOF to be encoded
in the data, EOF is a
*condition* detected by the OS. One can signal EOF from a
keyboard by pressing the key combination ctrl + 'z', usually
written as ^Z, on a DOS
based machine. I think that is what is referred to above, but
it has
nothing to do with files. Files are an *external*
representation of a data set, a keyboard is not an external
representation.
Many systems though *did* have a so-called end-of-file marker.
For DOS it's ASCII character code 26, which is generated by
pressing CTRL-Z. DOS doesn't use it itself but CP/M systems used
it to mark the end of valid data in a disk block.

Jul 20 '07 #12
"osmium" wrote:
>"Malcolm McLean" wrote:
>No. Text files often have a control Z as end of file marker. However on
most systems the text and binary formats are in fact identical.#

The most common form of text files use ASCII code, and there is no character
called 'control Z' in ASCII. Furthermore, I don't know of any compiler for
desktop computers that expects EOF to be encoded in the data, EOF is a
*condition* detected by the OS.
[Off-Topic] CP/M used a 0x1A character (a.k.a "Control-Z") as an EOF
marker "encoded in the data", since the OS kept track of file sizes
only as multiples of 128 byte blocks. (This convention was used only
in text files, obviously.)

Since every CP/M program that manipulated text expected this, and
Microsoft's DOS started its life as a CP/M look alike for the 8086/8
family, DOS programs also interpreted (and many still do) a CTRL-Z as
an EOF mark, and added automatically a CTRL-Z at the end of text files
when closing them. (Try COPYing a file that contains a CTRL-Z in a
Windows system, with and without the /B switch)

There is enough software relying on this, and enough files created
with a CTRL-Z at the end, that the C# language definition includes
provisions to deal with it:

"The C# Programming Language", 2nd ed., (c) 2006

2 - Lexical Structure ...
2.3 - Lexical Analysis ...
2.3.1 - Line Terminators ...
"If the last character of the source file is
a Control-Z character (U+001A) this
character is deleted"

I was forced to do the same eons ago, when writing C programs that had
to be portable between MSDOS, CP/M and DEC's operating systems.

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Jul 20 '07 #13
On 2007-07-20 14:10, Roberto Waltman <us****@rwaltman.netwrote:
"osmium" wrote:
>>"Malcolm McLean" wrote:
>>No. Text files often have a control Z as end of file marker. However on
most systems the text and binary formats are in fact identical.#

The most common form of text files use ASCII code, and there is no character
called 'control Z' in ASCII. Furthermore, I don't know of any compiler for
desktop computers that expects EOF to be encoded in the data, EOF is a
*condition* detected by the OS.

[Off-Topic] CP/M used a 0x1A character (a.k.a "Control-Z") as an EOF
marker "encoded in the data", since the OS kept track of file sizes
only as multiples of 128 byte blocks. (This convention was used only
in text files, obviously.)

Since every CP/M program that manipulated text expected this, and
Microsoft's DOS started its life as a CP/M look alike for the 8086/8
family, DOS programs also interpreted (and many still do) a CTRL-Z as
an EOF mark, and added automatically a CTRL-Z at the end of text files
when closing them.
[...]
I was forced to do the same eons ago, when writing C programs that had
to be portable between MSDOS, CP/M and DEC's operating systems.
When I wrote C programs for MS-DOS (eons ago), the stdio libraries of
the compilers I used at the time (Borland and Microsoft) did that
automatically if a file was opened in text mode.

hp

--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hj*@hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
Jul 23 '07 #14
"Peter J. Holzer" wrote:
>When I wrote C programs for MS-DOS (eons ago), the stdio libraries of
the compilers I used at the time (Borland and Microsoft) did that
[deleting control-Z]
>automatically if a file was opened in text mode.
Correct. I never had that problem with Borland or MS compilers. The
ones that gave me trouble were: a very early C compiler for DOS, (I
may have been one of the first versions of Lattice-C, I am not sure)
and another for VAS/VMS.
In the second case it was not the compiler's fault. I had to process
data produced by several programs run in sequence, the last one was
some file conversion utility that left the CTRL-Z in place when
producing a regular VMS record-oriented text file.
I found it easier to write a wrapper around the standard file
operations and use it in all systems, deleting a trailing CTRL-Z if it
was there, and doing nothing if it wasn't.

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Jul 27 '07 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
4884
by: Eric | last post by:
Assume that disk space is not an issue (the files will be small < 5k in general for the purpose of storing preferences) Assume that transportation to another OS may never occur. Are there...
0
3291
by: Steve | last post by:
My application uses transfertext to create text files that are FTPed to a website and are processed by a webstore. The text files can be for one of three purposes: Add one or more items to the...
16
2643
by: thenightfly | last post by:
Ok, I know all about how binary numbers translate into text characters. My question is what exactly IS a text character? Is it a bitmap?
0
2378
by: richardkreidl | last post by:
I have the following hash script that I use to compare two text files. 'Class Public Class FileComparison Public Class FileComparisonException Public Enum ExceptionType U 'Unknown A 'Add...
3
4251
by: Frustrated Developer via DotNetMonster.com | last post by:
I have posted a couple times on here already and found the user community to be very helpful. I took on a project before I realized how difficult a time I'm having working with a database....
10
3627
by: joelagnel | last post by:
hi friends, i've been having this confusion for about a year, i want to know the exact difference between text and binary files. using the fwrite function in c, i wrote 2 bytes of integers in...
5
3154
by: praveenholal | last post by:
Hi Freinds , I want to convert the files that are in text format (.txt) to CSV file. I am working on Linux. So can anyone guide me. Here is my problem Description I have some result files...
29
4833
by: list | last post by:
Hi folks, I am new to Googlegroups. I asked my questions at other forums, since now. I have an important question: I have to check files if they are binary(.bmp, .avi, .jpg) or text(.txt,...
1
3416
by: Xah Lee | last post by:
Text Processing with Emacs Lisp Xah Lee, 2007-10-29 This page gives a outline of how to use emacs lisp to do text processing, using a specific real-world problem as example. If you don't know...
0
10707
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5089
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.