comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: checking if file is dos textfile or unix textfile ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: checking if file is dos textfile or unix textfile ? [message #38619] Fri, 19 March 2004 11:14 Go to next message
Norbert Hahn is currently offline  Norbert Hahn
Messages: 46
Registered: May 2003
Member
Michael Wallace <mwallace.removethismunge@swri.edu.invalid> wrote:

> Is there some specific file-reading issue you're having? As far as I
> know, there is no difference between reading DOS-formatted and
> UNIX-formatted files no matter what OS you're using. As a test, I just
> read in a DOS-formatted text file on my Linux box without any problems.

As long as you restrict yourself to the 96 printable ASCII characters
there are no differences except for the new line characters. However,
characterset extensions i.e. for national characters differ between
DOS and Windows.

Norbert
Re: checking if file is dos textfile or unix textfile ? [message #38625 is a reply to message #38619] Fri, 19 March 2004 08:19 Go to previous messageGo to next message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> following from a question some months ago, this question arised:
> how can I check if a textfile is dos or unix formatted ? Which way do I
> have to open it in IDL under windows (older IDL version 5.2.1) ? How do
> I have to read from the file to check the format ?

Is there some specific file-reading issue you're having? As far as I
know, there is no difference between reading DOS-formatted and
UNIX-formatted files no matter what OS you're using. As a test, I just
read in a DOS-formatted text file on my Linux box without any problems.

There are two UNIX utility programs, dos2unix and unix2dos which convert
files back and forth between the formats. If you want to make sure that
all of your files are of the same format, just run all of them through
the appropriate converter.

-Mike
Re: checking if file is dos textfile or unix textfile ? [message #38626 is a reply to message #38625] Fri, 19 March 2004 07:56 Go to previous messageGo to next message
Norbert Hahn is currently offline  Norbert Hahn
Messages: 46
Registered: May 2003
Member
Reimar Bauer <R.Bauer@fz-juelich.de> wrote:

> You could read the file in binary and test if 10b is followed by 13b.
> if this is true then it is a dos file.

If I'm not mistaken the sequence is CR followed by LF.

Norbert
Re: checking if file is dos textfile or unix textfile ? [message #38630 is a reply to message #38626] Fri, 19 March 2004 06:26 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Klemens Barfus wrote:
> Hello together,
> following from a question some months ago, this question arised:
> how can I check if a textfile is dos or unix formatted ? Which way do I
> have to open it in IDL under windows (older IDL version 5.2.1) ? How do
> I have to read from the file to check the format ?
>
> Thanks for your help in advance !
>
> Klemens
>

What kind of problems do you have?


You could read the file in binary and test if 10b is followed by 13b.
if this is true then it is a dos file.

If you don't move a pointer in the file then you should be able to read
it the same way on both platforms.

Otherwise a good trick is to use get_file() and put_file to make a local
copy into the /tmp directory and work on that one.

Reimar
--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
Re: checking if file is dos textfile or unix textfile ? [message #38713 is a reply to message #38626] Sat, 20 March 2004 01:15 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Norbert Hahn wrote:

> Reimar Bauer <R.Bauer@fz-juelich.de> wrote:
>
>> You could read the file in binary and test if 10b is followed by 13b.
>> if this is true then it is a dos file.
>
> If I'm not mistaken the sequence is CR followed by LF.
>
> Norbert


you are right I am a long time ago have used DOS

Reimar
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Color table editor
Next Topic: STRETCH: A bug?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:15:45 PDT 2025

Total time taken to generate the page: 0.00769 seconds