Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Usage: fortune -P [] -a [xsz] [Q: [file]] [rKe9] -v6[+] dataspec ... inputdir


devel / comp.lang.ada / Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

SubjectAuthor
* Using "pure" (?) Ada, how to determine whether a file is a "text"Kenneth Wolcott
`* Re: Using "pure" (?) Ada, how to determine whether a file is a "text"Jeffrey R.Carter
 `* Re: Using "pure" (?) Ada, how to determine whether a file is a "text"Kenneth Wolcott
  `* Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not Keith Thompson
   `* Re: Using "pure" (?) Ada, how to determine whether a file is a "text"Kenneth Wolcott
    `* Re: Using "pure" (?) Ada, how to determine whether a file is a "text"Chris Townley
     `- Re: Using "pure" (?) Ada, how to determine whether a file is a "text"Kenneth Wolcott

1
Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

<41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9794&group=comp.lang.ada#9794

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:45a8:b0:762:3d49:c90e with SMTP id bp40-20020a05620a45a800b007623d49c90emr15926qkb.6.1688231726403;
Sat, 01 Jul 2023 10:15:26 -0700 (PDT)
X-Received: by 2002:a25:1ed6:0:b0:bff:4ed0:63f6 with SMTP id
e205-20020a251ed6000000b00bff4ed063f6mr46155ybe.7.1688231725968; Sat, 01 Jul
2023 10:15:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 1 Jul 2023 10:15:25 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns
NNTP-Posting-Host: 98.59.238.112
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com>
Subject: Using "pure" (?) Ada, how to determine whether a file is a "text"
file, not a binary?
From: kennethwolcott@gmail.com (Kenneth Wolcott)
Injection-Date: Sat, 01 Jul 2023 17:15:26 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1877
 by: Kenneth Wolcott - Sat, 1 Jul 2023 17:15 UTC

Hi;

Another very beginner question here...

Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

Kind of like using the UNIX/Linux "file" command, but doesn't have to be comprehensive (yet). Something like the Perl "-T" feature.

On the other hand, if there already exists an Ada implementation of the UNIX "file" command as a library, could you point me to that?

As a side question, how does one read "binary" files in Ada?

A UNIX/Linux use case for the previous sentence is the concatenation of two (or more) "binary" files that were created using the UNIX/Linux "split" command.

So I'd be interested in emulating the UNIX "cat" command for "binary" files.

These are just personal experiments for learning how to do all kinds of Ada I/O...

Thanks,
Ken Wolcott

Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

<u7q2tv$2u2pl$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9795&group=comp.lang.ada#9795

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Using "pure" (?) Ada, how to determine whether a file is a "text"
file, not a binary?
Date: Sat, 1 Jul 2023 22:39:27 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <u7q2tv$2u2pl$1@dont-email.me>
References: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 1 Jul 2023 20:39:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4b0b3723792c49dee6ad8f9e712830d1";
logging-data="3083061"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jkv/EymNrIJVRS3JmcTRPElv3kkqFMr0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:q8b/4fEkAnsY3K46W67LcGYLado=
Content-Language: en-US
In-Reply-To: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com>
 by: Jeffrey R.Carter - Sat, 1 Jul 2023 20:39 UTC

On 2023-07-01 19:15, Kenneth Wolcott wrote:
>
> Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

That depends on the definition of a text file. Under Unix and Windows, all files
are sequences of bytes, and so may be considered sequences of Characters, and so
text files.

If you can define what distinguishes text files from binary files, then it
should be fairly easy to write Ada to distinguish them.

For example, if a text file is one in which all the characters, except line
terminators, are graphic characters, then it should be clear how to determine
whether a file meets that definition of a text file.

> As a side question, how does one read "binary" files in Ada?

Ada has Direct_IO, Sequential_IO, and Stream_IO for reading binary files. Which
you would use and how to use it depends on what's in the file and what you need
to do with it.

--
Jeff Carter
"Ada is the only language where users are
happy to have compilation errors!"
Jean-Pierre Rosen
166

Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

<a53a6fbd-c26b-4dd4-928c-7573e5daf0ean@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9796&group=comp.lang.ada#9796

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5b03:0:b0:3f9:aa64:7dbf with SMTP id m3-20020ac85b03000000b003f9aa647dbfmr33873qtw.4.1688244892262;
Sat, 01 Jul 2023 13:54:52 -0700 (PDT)
X-Received: by 2002:a25:4254:0:b0:c4f:f5f:9e7e with SMTP id
p81-20020a254254000000b00c4f0f5f9e7emr3239yba.2.1688244891938; Sat, 01 Jul
2023 13:54:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 1 Jul 2023 13:54:51 -0700 (PDT)
In-Reply-To: <u7q2tv$2u2pl$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns
NNTP-Posting-Host: 98.59.238.112
References: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com> <u7q2tv$2u2pl$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a53a6fbd-c26b-4dd4-928c-7573e5daf0ean@googlegroups.com>
Subject: Re: Using "pure" (?) Ada, how to determine whether a file is a "text"
file, not a binary?
From: kennethwolcott@gmail.com (Kenneth Wolcott)
Injection-Date: Sat, 01 Jul 2023 20:54:52 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2519
 by: Kenneth Wolcott - Sat, 1 Jul 2023 20:54 UTC

On Saturday, July 1, 2023 at 1:39:30 PM UTC-7, Jeffrey R.Carter wrote:
> On 2023-07-01 19:15, Kenneth Wolcott wrote:
> >
> > Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?
> That depends on the definition of a text file. Under Unix and Windows, all files
> are sequences of bytes, and so may be considered sequences of Characters, and so
> text files.
>
> If you can define what distinguishes text files from binary files, then it
> should be fairly easy to write Ada to distinguish them.
>
> For example, if a text file is one in which all the characters, except line
> terminators, are graphic characters, then it should be clear how to determine
> whether a file meets that definition of a text file.

I think that is the definition that I'm going to pursue as the simplest and effective definition.

> > As a side question, how does one read "binary" files in Ada?
> Ada has Direct_IO, Sequential_IO, and Stream_IO for reading binary files. Which
> you would use and how to use it depends on what's in the file and what you need
> to do with it.

Ok, now that seems to be pretty obvious! I'll go and experiment further....

Thank you!
Ken

Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

<87edlrxqfd.fsf@nosuchdomain.example.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9797&group=comp.lang.ada#9797

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.ada
Subject: Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?
Date: Sat, 01 Jul 2023 14:39:02 -0700
Organization: None to speak of
Lines: 22
Message-ID: <87edlrxqfd.fsf@nosuchdomain.example.com>
References: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com>
<u7q2tv$2u2pl$1@dont-email.me>
<a53a6fbd-c26b-4dd4-928c-7573e5daf0ean@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="b7dd3dc39b8f7f61e15fc922c859854e";
logging-data="3196166"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CBbBblSoW28ywY/mMbEI5"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:PikyfQR/sH29FJ3PSWhNrUfqFNI=
sha1:tNEAWZCX7J0mOLO3sW6sSQvunXE=
 by: Keith Thompson - Sat, 1 Jul 2023 21:39 UTC

Kenneth Wolcott <kennethwolcott@gmail.com> writes:
> On Saturday, July 1, 2023 at 1:39:30 PM UTC-7, Jeffrey R.Carter wrote:
>> On 2023-07-01 19:15, Kenneth Wolcott wrote:
[...]
>> For example, if a text file is one in which all the characters, except line
>> terminators, are graphic characters, then it should be clear how to determine
>> whether a file meets that definition of a text file.
>
> I think that is the definition that I'm going to pursue as the
> simplest and effective definition.

Think about how you want to handle tab characters (non-graphic but
common in some text) and carriage return characters (non-graphic but
part of a line terminator for Windows-style text files).

Also think about the various ways of representing text: ASCII, Latin-1,
UTF-8, UTF-16, etc.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

<48b33023-a38e-4ccc-855e-fe6de7b12ea5n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9798&group=comp.lang.ada#9798

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:584b:b0:635:e500:8dc7 with SMTP id ml11-20020a056214584b00b00635e5008dc7mr53004qvb.4.1688248233904;
Sat, 01 Jul 2023 14:50:33 -0700 (PDT)
X-Received: by 2002:a05:6a00:14d6:b0:675:70d7:1eb0 with SMTP id
w22-20020a056a0014d600b0067570d71eb0mr8112534pfu.6.1688248233382; Sat, 01 Jul
2023 14:50:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 1 Jul 2023 14:50:32 -0700 (PDT)
In-Reply-To: <87edlrxqfd.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns
NNTP-Posting-Host: 98.59.238.112
References: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com>
<u7q2tv$2u2pl$1@dont-email.me> <a53a6fbd-c26b-4dd4-928c-7573e5daf0ean@googlegroups.com>
<87edlrxqfd.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <48b33023-a38e-4ccc-855e-fe6de7b12ea5n@googlegroups.com>
Subject: Re: Using "pure" (?) Ada, how to determine whether a file is a "text"
file, not a binary?
From: kennethwolcott@gmail.com (Kenneth Wolcott)
Injection-Date: Sat, 01 Jul 2023 21:50:33 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2446
 by: Kenneth Wolcott - Sat, 1 Jul 2023 21:50 UTC

On Saturday, July 1, 2023 at 2:39:06 PM UTC-7, Keith Thompson wrote:
> Kenneth Wolcott writes:
> > On Saturday, July 1, 2023 at 1:39:30 PM UTC-7, Jeffrey R.Carter wrote:
> >> On 2023-07-01 19:15, Kenneth Wolcott wrote:
> [...]
> >> For example, if a text file is one in which all the characters, except line
> >> terminators, are graphic characters, then it should be clear how to determine
> >> whether a file meets that definition of a text file.
> >
> > I think that is the definition that I'm going to pursue as the
> > simplest and effective definition.
> Think about how you want to handle tab characters (non-graphic but
> common in some text) and carriage return characters (non-graphic but
> part of a line terminator for Windows-style text files).
>
> Also think about the various ways of representing text: ASCII, Latin-1,
> UTF-8, UTF-16, etc.

Thanks, Keith!

It looks like just need to more carefully examine the existing Ada I/O packages and experiment with the possibilities...

Ken

Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

<u7qim2$2tdvh$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9799&group=comp.lang.ada#9799

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: news@cct-net.co.uk (Chris Townley)
Newsgroups: comp.lang.ada
Subject: Re: Using "pure" (?) Ada, how to determine whether a file is a "text"
file, not a binary?
Date: Sun, 2 Jul 2023 02:08:17 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <u7qim2$2tdvh$1@dont-email.me>
References: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com>
<u7q2tv$2u2pl$1@dont-email.me>
<a53a6fbd-c26b-4dd4-928c-7573e5daf0ean@googlegroups.com>
<87edlrxqfd.fsf@nosuchdomain.example.com>
<48b33023-a38e-4ccc-855e-fe6de7b12ea5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 2 Jul 2023 01:08:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b1cd67f8872ec3b52ff4de6d2fd45e81";
logging-data="3061745"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oRF7F7689XegX9wZMsDgOJKydVmGqQts="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.12.0
Cancel-Lock: sha1:3MdXo2NebNpDg4l8xrB+6XAFVIc=
Content-Language: en-GB
In-Reply-To: <48b33023-a38e-4ccc-855e-fe6de7b12ea5n@googlegroups.com>
 by: Chris Townley - Sun, 2 Jul 2023 01:08 UTC

On 01/07/2023 22:50, Kenneth Wolcott wrote:
> On Saturday, July 1, 2023 at 2:39:06 PM UTC-7, Keith Thompson wrote:
>> Kenneth Wolcott writes:
>>> On Saturday, July 1, 2023 at 1:39:30 PM UTC-7, Jeffrey R.Carter wrote:
>>>> On 2023-07-01 19:15, Kenneth Wolcott wrote:
>> [...]
>>>> For example, if a text file is one in which all the characters, except line
>>>> terminators, are graphic characters, then it should be clear how to determine
>>>> whether a file meets that definition of a text file.
>>>
>>> I think that is the definition that I'm going to pursue as the
>>> simplest and effective definition.
>> Think about how you want to handle tab characters (non-graphic but
>> common in some text) and carriage return characters (non-graphic but
>> part of a line terminator for Windows-style text files).
>>
>> Also think about the various ways of representing text: ASCII, Latin-1,
>> UTF-8, UTF-16, etc.
>
> Thanks, Keith!
>
> It looks like just need to more carefully examine the existing Ada I/O packages and experiment with the possibilities...
>
> Ken

Maybe worth looking at the unix file utility, docs and source are available
--
Chris

Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

<74f92ce6-851f-4074-8f3a-549b64555b18n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9800&group=comp.lang.ada#9800

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:45a8:b0:765:94ad:379d with SMTP id bp40-20020a05620a45a800b0076594ad379dmr18763qkb.6.1688262536422;
Sat, 01 Jul 2023 18:48:56 -0700 (PDT)
X-Received: by 2002:a17:902:c246:b0:1a9:8f00:bf6e with SMTP id
6-20020a170902c24600b001a98f00bf6emr4956446plg.3.1688262536170; Sat, 01 Jul
2023 18:48:56 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 1 Jul 2023 18:48:55 -0700 (PDT)
In-Reply-To: <u7qim2$2tdvh$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns
NNTP-Posting-Host: 98.59.238.112
References: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com>
<u7q2tv$2u2pl$1@dont-email.me> <a53a6fbd-c26b-4dd4-928c-7573e5daf0ean@googlegroups.com>
<87edlrxqfd.fsf@nosuchdomain.example.com> <48b33023-a38e-4ccc-855e-fe6de7b12ea5n@googlegroups.com>
<u7qim2$2tdvh$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <74f92ce6-851f-4074-8f3a-549b64555b18n@googlegroups.com>
Subject: Re: Using "pure" (?) Ada, how to determine whether a file is a "text"
file, not a binary?
From: kennethwolcott@gmail.com (Kenneth Wolcott)
Injection-Date: Sun, 02 Jul 2023 01:48:56 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2972
 by: Kenneth Wolcott - Sun, 2 Jul 2023 01:48 UTC

On Saturday, July 1, 2023 at 6:08:21 PM UTC-7, Chris Townley wrote:
> On 01/07/2023 22:50, Kenneth Wolcott wrote:
> > On Saturday, July 1, 2023 at 2:39:06 PM UTC-7, Keith Thompson wrote:
> >> Kenneth Wolcott writes:
> >>> On Saturday, July 1, 2023 at 1:39:30 PM UTC-7, Jeffrey R.Carter wrote:
> >>>> On 2023-07-01 19:15, Kenneth Wolcott wrote:
> >> [...]
> >>>> For example, if a text file is one in which all the characters, except line
> >>>> terminators, are graphic characters, then it should be clear how to determine
> >>>> whether a file meets that definition of a text file.
> >>>
> >>> I think that is the definition that I'm going to pursue as the
> >>> simplest and effective definition.
> >> Think about how you want to handle tab characters (non-graphic but
> >> common in some text) and carriage return characters (non-graphic but
> >> part of a line terminator for Windows-style text files).
> >>
> >> Also think about the various ways of representing text: ASCII, Latin-1,
> >> UTF-8, UTF-16, etc.
> >
> > Thanks, Keith!
> >
> > It looks like just need to more carefully examine the existing Ada I/O packages and experiment with the possibilities...
> >
> > Ken
> Maybe worth looking at the unix file utility, docs and source are available

Thank you, Chris.

I have just downloaded the source code for the UNIX/Linus file command and am browsing around...

Thanks,
Ken

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor