Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

6 May, 2024: The networking issue during the past two days has been identified and appears to be fixed. Will keep monitoring.


devel / comp.lang.xharbour / Text File for uploading to DBF delimited CRLF vs LF (Windows)

SubjectAuthor
* Text File for uploading to DBF delimited CRLF vs LF (Windows)poopall
+* Text File for uploading to DBF delimited CRLF vs LF (Windows)dlzc
|`* Text File for uploading to DBF delimited CRLF vs LF (Windows)poopall
| +- Text File for uploading to DBF delimited CRLF vs LF (Windows)dlzc
| `* Text File for uploading to DBF delimited CRLF vs LF (Windows)dlzc
|  `* Text File for uploading to DBF delimited CRLF vs LF (Windows)poopall
|   `- Text File for uploading to DBF delimited CRLF vs LF (Windows)dlzc
`- Text File for uploading to DBF delimited CRLF vs LF (Windows)Dan

1
Text File for uploading to DBF delimited CRLF vs LF (Windows)

<ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10592&group=comp.lang.xharbour#10592

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:ac8:59d2:0:b0:343:57f:3049 with SMTP id f18-20020ac859d2000000b00343057f3049mr2621373qtf.55.1661418077845;
Thu, 25 Aug 2022 02:01:17 -0700 (PDT)
X-Received: by 2002:a25:8a0e:0:b0:692:8410:1a8e with SMTP id
g14-20020a258a0e000000b0069284101a8emr2417979ybl.621.1661418077545; Thu, 25
Aug 2022 02:01:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.xharbour
Date: Thu, 25 Aug 2022 02:01:17 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=119.18.31.162; posting-account=zx0oKAkAAABMkjQR74hmeFvHN7cev7io
NNTP-Posting-Host: 119.18.31.162
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>
Subject: Text File for uploading to DBF delimited CRLF vs LF (Windows)
From: lawrence...@gmail.com (poopall)
Injection-Date: Thu, 25 Aug 2022 09:01:17 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1287
 by: poopall - Thu, 25 Aug 2022 09:01 UTC

I have recently received a txt file which it appears has LF as the end of line markets, windows required CRLF

Is there a function call to easily test for this condition before attempting a append "delimited".

I would be nice if there as an automatic conversion

Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)

<2309c9e7-b2d8-44a0-bbb1-4df3943ebdcan@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10595&group=comp.lang.xharbour#10595

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:620a:7e2:b0:6bc:980:db39 with SMTP id k2-20020a05620a07e200b006bc0980db39mr4455145qkk.176.1661459555987;
Thu, 25 Aug 2022 13:32:35 -0700 (PDT)
X-Received: by 2002:a0d:dd53:0:b0:33b:78a3:85dc with SMTP id
g80-20020a0ddd53000000b0033b78a385dcmr5567986ywe.218.1661459555768; Thu, 25
Aug 2022 13:32:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.xharbour
Date: Thu, 25 Aug 2022 13:32:35 -0700 (PDT)
In-Reply-To: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=68.107.209.13; posting-account=7bF0GwoAAABMFHX6V4fON4-1F6LFJ834
NNTP-Posting-Host: 68.107.209.13
References: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2309c9e7-b2d8-44a0-bbb1-4df3943ebdcan@googlegroups.com>
Subject: Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)
From: dlz...@cox.net (dlzc)
Injection-Date: Thu, 25 Aug 2022 20:32:35 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2027
 by: dlzc - Thu, 25 Aug 2022 20:32 UTC

On Thursday, August 25, 2022 at 2:01:18 AM UTC-7, poopall wrote:
> I have recently received a txt file which it appears has LF as the end
> of line markets, windows required CRLF
>
> Is there a function call to easily test for this condition before
> attempting a append "delimited".

Read in the "first 1000" characters, and see if any chr(13) are in the string. That should tell you.
> I would be nice if there as an automatic conversion

There is, at the source.
https://www.hanselman.com/blog/carriage-returns-and-line-feeds-will-ultimately-bite-you-some-git-tips

Might be a "RUN" command / call...
https://waterlan.home.xs4all.nl/dos2unix.html
.... you'd want the reverse. Might find out what would happen if you always pushed the file (Linux or DOS) through dos2unix first, then back through unix2dos. MIGHT save even doing a check.

David A. Smith

Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)

<2eceac47-407d-4ca9-8fb7-389bb677dc50n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10596&group=comp.lang.xharbour#10596

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:ae9:ed89:0:b0:6bb:9968:de30 with SMTP id c131-20020ae9ed89000000b006bb9968de30mr5083555qkg.774.1661476885857;
Thu, 25 Aug 2022 18:21:25 -0700 (PDT)
X-Received: by 2002:a5b:68c:0:b0:690:aa11:d7af with SMTP id
j12-20020a5b068c000000b00690aa11d7afmr5530849ybq.253.1661476885241; Thu, 25
Aug 2022 18:21:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.xharbour
Date: Thu, 25 Aug 2022 18:21:24 -0700 (PDT)
In-Reply-To: <2309c9e7-b2d8-44a0-bbb1-4df3943ebdcan@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=119.18.31.162; posting-account=zx0oKAkAAABMkjQR74hmeFvHN7cev7io
NNTP-Posting-Host: 119.18.31.162
References: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com> <2309c9e7-b2d8-44a0-bbb1-4df3943ebdcan@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2eceac47-407d-4ca9-8fb7-389bb677dc50n@googlegroups.com>
Subject: Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)
From: lawrence...@gmail.com (poopall)
Injection-Date: Fri, 26 Aug 2022 01:21:25 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2738
 by: poopall - Fri, 26 Aug 2022 01:21 UTC

On Friday, 26 August 2022 at 6:32:36 am UTC+10, dlzc wrote:
> On Thursday, August 25, 2022 at 2:01:18 AM UTC-7, poopall wrote:
> > I have recently received a txt file which it appears has LF as the end
> > of line markets, windows required CRLF
> >
> > Is there a function call to easily test for this condition before
> > attempting a append "delimited".
> Read in the "first 1000" characters, and see if any chr(13) are in the string. That should tell you.
> > I would be nice if there as an automatic conversion
> There is, at the source.
> https://www.hanselman.com/blog/carriage-returns-and-line-feeds-will-ultimately-bite-you-some-git-tips
>
> Might be a "RUN" command / call...
> https://waterlan.home.xs4all.nl/dos2unix.html
> ... you'd want the reverse. Might find out what would happen if you always pushed the file (Linux or DOS) through dos2unix first, then back through unix2dos. MIGHT save even doing a check.
>
> David A. Smith

The problem is its not apparent that the .txt file received is in UNIX format, as the CR or LF are hidden symbol.

When dealing with this issue one does not always assume a txt file is anything but CRLF when working in windows, being windows centric.

Many wasted hours thinking I have lost my mind, as only 1st line could be read.

Simple solution for me was to use Notepad++ and convert EOL to Windows

It would be nice if there was a function to check for this condition in a file (hoping someone will create something)

Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)

<65453dd6-1e56-463c-a0c4-3a4322d231a5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10598&group=comp.lang.xharbour#10598

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:622a:11d2:b0:343:67a1:85e8 with SMTP id n18-20020a05622a11d200b0034367a185e8mr8013638qtk.11.1661522718801;
Fri, 26 Aug 2022 07:05:18 -0700 (PDT)
X-Received: by 2002:a05:6902:1502:b0:695:a994:475c with SMTP id
q2-20020a056902150200b00695a994475cmr7673868ybu.547.1661522718371; Fri, 26
Aug 2022 07:05:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.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.xharbour
Date: Fri, 26 Aug 2022 07:05:18 -0700 (PDT)
In-Reply-To: <2eceac47-407d-4ca9-8fb7-389bb677dc50n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=68.107.209.13; posting-account=7bF0GwoAAABMFHX6V4fON4-1F6LFJ834
NNTP-Posting-Host: 68.107.209.13
References: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>
<2309c9e7-b2d8-44a0-bbb1-4df3943ebdcan@googlegroups.com> <2eceac47-407d-4ca9-8fb7-389bb677dc50n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <65453dd6-1e56-463c-a0c4-3a4322d231a5n@googlegroups.com>
Subject: Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)
From: dlz...@cox.net (dlzc)
Injection-Date: Fri, 26 Aug 2022 14:05:18 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2894
 by: dlzc - Fri, 26 Aug 2022 14:05 UTC

On Thursday, August 25, 2022 at 6:21:26 PM UTC-7, poopall wrote:
> On Friday, 26 August 2022 at 6:32:36 am UTC+10, dlzc wrote:
> > On Thursday, August 25, 2022 at 2:01:18 AM UTC-7, poopall wrote:
> > > I have recently received a txt file which it appears has LF as the end
> > > of line markets, windows required CRLF
> > >
> > > Is there a function call to easily test for this condition before
> > > attempting a append "delimited".
> > Read in the "first 1000" characters, and see if any chr(13) are in the string. That should tell you.
> > > I would be nice if there as an automatic conversion
> > There is, at the source.
> > https://www.hanselman.com/blog/carriage-returns-and-line-feeds-will-ultimately-bite-you-some-git-tips
> >
> > Might be a "RUN" command / call...
> > https://waterlan.home.xs4all.nl/dos2unix.html
> > ... you'd want the reverse. Might find out what would happen if you always pushed the file (Linux or DOS) through dos2unix first, then back through unix2dos. MIGHT save even doing a check.
> >
> > David A. Smith
> The problem is its not apparent that the .txt file received is in UNIX format, as the CR or LF are hidden symbol.
>
> When dealing with this issue one does not always assume a txt file is anything but CRLF when working in windows, being windows centric.
>
> Many wasted hours thinking I have lost my mind, as only 1st line could be read.
>
> Simple solution for me was to use Notepad++ and convert EOL to Windows
>
> It would be nice if there was a function to check for this condition in a file (hoping someone will create something)

Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)

<5a1f0e83-45c7-4fa5-965e-b7c2d652c687n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10599&group=comp.lang.xharbour#10599

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:6214:2aa6:b0:474:844b:24ff with SMTP id js6-20020a0562142aa600b00474844b24ffmr8367613qvb.51.1661523299380;
Fri, 26 Aug 2022 07:14:59 -0700 (PDT)
X-Received: by 2002:a81:914c:0:b0:33d:d15e:1b50 with SMTP id
i73-20020a81914c000000b0033dd15e1b50mr3053177ywg.292.1661523299106; Fri, 26
Aug 2022 07:14:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.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.xharbour
Date: Fri, 26 Aug 2022 07:14:58 -0700 (PDT)
In-Reply-To: <2eceac47-407d-4ca9-8fb7-389bb677dc50n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=68.107.209.13; posting-account=7bF0GwoAAABMFHX6V4fON4-1F6LFJ834
NNTP-Posting-Host: 68.107.209.13
References: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>
<2309c9e7-b2d8-44a0-bbb1-4df3943ebdcan@googlegroups.com> <2eceac47-407d-4ca9-8fb7-389bb677dc50n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5a1f0e83-45c7-4fa5-965e-b7c2d652c687n@googlegroups.com>
Subject: Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)
From: dlz...@cox.net (dlzc)
Injection-Date: Fri, 26 Aug 2022 14:14:59 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1671
 by: dlzc - Fri, 26 Aug 2022 14:14 UTC

Dear poopall:

On Thursday, August 25, 2022 at 6:21:26 PM UTC-7, poopall wrote:

local cBuffer := ""
local hasCR := .F.
nReadMe := fopen( "Suspect.txt", FO_READ + FO_DENYNONE )
fread( nReadMe, @cBuffer, 1000 ) ;hopefully less than 100 character records
hasCR := ( at( chr(13), cBuffer ) > 0 )
fclose( nReadMe )
release cBuffer

.... hasCR is true if there is a carriage return.

David A. Smith

Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)

<9a96f5f3-4ffd-45f2-b069-b6b11e287e16n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10602&group=comp.lang.xharbour#10602

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:620a:4709:b0:6bb:331b:5f6a with SMTP id bs9-20020a05620a470900b006bb331b5f6amr7007326qkb.96.1661739595906;
Sun, 28 Aug 2022 19:19:55 -0700 (PDT)
X-Received: by 2002:a81:4e8e:0:b0:340:b324:8920 with SMTP id
c136-20020a814e8e000000b00340b3248920mr7241480ywb.218.1661739595649; Sun, 28
Aug 2022 19:19:55 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.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.xharbour
Date: Sun, 28 Aug 2022 19:19:55 -0700 (PDT)
In-Reply-To: <5a1f0e83-45c7-4fa5-965e-b7c2d652c687n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=119.18.31.162; posting-account=zx0oKAkAAABMkjQR74hmeFvHN7cev7io
NNTP-Posting-Host: 119.18.31.162
References: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>
<2309c9e7-b2d8-44a0-bbb1-4df3943ebdcan@googlegroups.com> <2eceac47-407d-4ca9-8fb7-389bb677dc50n@googlegroups.com>
<5a1f0e83-45c7-4fa5-965e-b7c2d652c687n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9a96f5f3-4ffd-45f2-b069-b6b11e287e16n@googlegroups.com>
Subject: Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)
From: lawrence...@gmail.com (poopall)
Injection-Date: Mon, 29 Aug 2022 02:19:55 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1935
 by: poopall - Mon, 29 Aug 2022 02:19 UTC

On Saturday, 27 August 2022 at 12:15:00 am UTC+10, dlzc wrote:
> Dear poopall:
>
> On Thursday, August 25, 2022 at 6:21:26 PM UTC-7, poopall wrote:
>
> local cBuffer := ""
> local hasCR := .F.
> nReadMe := fopen( "Suspect.txt", FO_READ + FO_DENYNONE )
> fread( nReadMe, @cBuffer, 1000 ) ;hopefully less than 100 character records
> hasCR := ( at( chr(13), cBuffer ) > 0 )
> fclose( nReadMe )
> release cBuffer
>
> ... hasCR is true if there is a carriage return.
>
> David A. Smith
Thank U, how about a routine that changes all of the to CRLF if they are only LF

Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)

<fe3d98f3-8ec9-424f-a016-f65505f49b30n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10603&group=comp.lang.xharbour#10603

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:622a:1b01:b0:343:582f:3e07 with SMTP id bb1-20020a05622a1b0100b00343582f3e07mr10959350qtb.578.1661793096279;
Mon, 29 Aug 2022 10:11:36 -0700 (PDT)
X-Received: by 2002:a25:938c:0:b0:695:7952:6ed7 with SMTP id
a12-20020a25938c000000b0069579526ed7mr9313813ybm.116.1661793096135; Mon, 29
Aug 2022 10:11:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.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.xharbour
Date: Mon, 29 Aug 2022 10:11:35 -0700 (PDT)
In-Reply-To: <9a96f5f3-4ffd-45f2-b069-b6b11e287e16n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=68.107.209.13; posting-account=7bF0GwoAAABMFHX6V4fON4-1F6LFJ834
NNTP-Posting-Host: 68.107.209.13
References: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>
<2309c9e7-b2d8-44a0-bbb1-4df3943ebdcan@googlegroups.com> <2eceac47-407d-4ca9-8fb7-389bb677dc50n@googlegroups.com>
<5a1f0e83-45c7-4fa5-965e-b7c2d652c687n@googlegroups.com> <9a96f5f3-4ffd-45f2-b069-b6b11e287e16n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fe3d98f3-8ec9-424f-a016-f65505f49b30n@googlegroups.com>
Subject: Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)
From: dlz...@cox.net (dlzc)
Injection-Date: Mon, 29 Aug 2022 17:11:36 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2620
 by: dlzc - Mon, 29 Aug 2022 17:11 UTC

Dear poopall:

On Sunday, August 28, 2022 at 7:19:56 PM UTC-7, poopall wrote:
> On Saturday, 27 August 2022 at 12:15:00 am UTC+10, dlzc wrote:
....
> Thank U, how about a routine that changes all of the to CRLF
> if they are only LF

Open the file
Read (up to 1000 characters) until CR is found
if found, terminate and proceed with your APPEND
If eof() or 1000 characters
create temporary file (errors?)
read 100 characters (or EOF())
place each character in buffer unless it is a LF (and previous was not CR), then place CRLF in buffer and continue
write buffer to second file
if .not. eof() loop
if errors stop, do not allow APPEND
close source
close copy
delete source (errors?)
rename copy to source name
release whatever variables you don't need.
Proceed with APPEND.

Now you could add making sure no blank lines are added, and try squirting characters into the same strings (rather than reallocating string space), but that is an exercise for another day.

Me, I'd use the utilities I pointed out to you earlier. I've got a 6000+ record database that describe key elements of movie files, and you can be sure I didn't learn how to parse all possible movie formats...

David A. Smith

Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)

<tejcfs$18j0s$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10604&group=comp.lang.xharbour#10604

  copy link   Newsgroups: comp.lang.xharbour
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: webmas...@appliserver.com (Dan)
Newsgroups: comp.lang.xharbour
Subject: Re: Text File for uploading to DBF delimited CRLF vs LF (Windows)
Date: Mon, 29 Aug 2022 23:52:58 +0200
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <tejcfs$18j0s$1@dont-email.me>
References: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 29 Aug 2022 21:53:00 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="6a2946a62185b1b68d0f261ea6cc86f9";
logging-data="1330204"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZDrl9N+R/oi0gSIBu8Lh+"
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Cancel-Lock: sha1:iiVYOdReuNzEN7Un4ubU4wYEMuk=
In-Reply-To: <ba35c9fb-3def-46a6-897e-f5fb9818ad2bn@googlegroups.com>
 by: Dan - Mon, 29 Aug 2022 21:52 UTC

Il 25/08/2022 11:01, poopall ha scritto:
> I have recently received a txt file which it appears has LF as the end of line markets, windows required CRLF
>
> Is there a function call to easily test for this condition before attempting a append "delimited".
>
> I would be nice if there as an automatic conversion

I know of 3 possibilities: CR is line end (Apple), LF is line end
(nixes) and CRLF is line end (Win).

fopen() the txt. Read one char at a time. Use 3 vars: cr_found,
lf_found, crlf_found. When you encounter CR or LF you consider the
subsequent character and determine the EOL.
You can have CR true and no LF subsequent, or CR and LF or LF and no
previous CR.

Now you can read line by line and write to a new normalized file with
the desired EOL.

readline - reads a line from a txt file
Usage: nRet = readline(<nhdl>,@cBuffer [,<eol>])
Returns: 0 if eof not encountered, -1 if eof

// nHdl = handle of the file FOPENed
// cLine = buffer for line (pass for reference)
// eol = end-of-line
function readline(nHdl,cLine,eol)
local nEol:=.f.,RetVal:=0
local byte:=" ",z
if empty(eol)
eol = hb_osnewline() //hb_eol()
endif
cLine=""
do while .t.
z:=fread(nHdl,@byte,1)
if z=0
if len(cLine)=0
retval:=-1
endif
exit
endif
cLine=cLine+byte
if len(cLine)>=len(eol)
if right(cLine,len(eol))=eol
cLine=strtran(cLine,eol,"")
exit
endif
endif
enddo
return RetVal

-----
nHdlIn := fopen("suspect.txt",FO_READ)
nHdlOut := fcreate("normalized.txt", FO_WRITE)
buffer := ""
EOLIn := chr(10)
EOLOut := chr(13)+chr(10)

do while readline ( nHdl, @buffer, EolIn ) == 0
fwrite ( nHdlOut, buffer+EOLOut )
enddo
fclose ( nHdlIn )
fclose ( nHdlOut )

(UNTESTED)

HTH
Dan

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor