× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Charles,

Note that reading one byte at a time is going to perform very poorly.


It shouldn't perform too badly if you use fgetc() or fread(). When you use these APIs, the system will buffer the disk reads, and that'll perform much better. Not as well as reading larger blocks of data, mind you... but loads better than calling the read() API for one byte at a time.

What baffles me about this thread is how you can possibly read a CR/LF terminated line when there will be random binary data in the middle of the line. What if the data happens to contain a x'0d' or x'0a' (the hex values of CR and LF in ASCII -- subsitute x'0d' and x'25' if the data is EBCDIC) Surely, any routine intended to read lines that are CRLF terminated is going to be confused by that?

But, assuming that you know the values for CR and LF won't ever appear, except where they need to be to terminate the record, then you could simply write your own version of fgets() that doesn't do ASCII/EBCDIC translation (but still searches for x'0d' and x'0a'). Then do the translation manually where you need to. Just grab the code for an open source implementation of fgets() and implement the same algorithm in RPG. Indeed, this is what I have been working on for my TCPR4 service program (a service program for socket programming with TCP protocol).

Or use o_ccsid=(file ccsid) as Bruce suggested... I'd expect that this would effectively disable translation.

But, this seems like a very bizarre way to design a file. I can't see how this file layout would work well on any platform, regardless of ASCII/EBCDIC translation. Your file should either be binary or text. Trying to mix both together isn't a good idea (unless the binary is encoded somehow, such as base64). Otherwise you run into conflicts.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.