× 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 Steve,

I've another ASCII PC file which I need to read but only some of the
data is text. Some of the data is binary numbers so translating all
of the data doesn't get the job done. This file also has CRLF in the
records

Hmmm... well, it's not really an "ASCII PC file" if part of the data is binary, is it? :) It's a "Mixed ASCII & Binary PC file". Heh.

For situations like that, I do exactly what you describe. I read the file in binary mode (so no data is translated). This is done by leaving the O_TEXTDATA flag off of the open() API. (Leave off O_CCSID, O_CODEPAGE and O_TEXT_CREAT as well... but O_TEXTDATA is the crucial one.)

I can't say that I really use the readline() procedure in my production code. I just wrote that as an example in the IFS tutorial, it's been years since I've even looked at it. But, glancing at it now, it looks like all you have to do is change x'25' to x'0A' in the routine and it'll magically work on ASCII data instead of EBCDIC data.

Maybe you want to pass the "end of line" characters as parameters to the readline() and writeline() routines (like I demonstrated in the socket tutorial) to make it possible to read "lines" of any type of file.

Then, I'd use the iconv() API to translate the individual fields. Maybe create a nice re-usable wrapper for iconv() and stick it into the IFSTEXTR4 service program. The open() API calls iconv() under the covers, so if you coded your own call to iconv() you could provide the same support that open() does, but you'd be able to have finer grained control (such as the ability to translate by field instead of by record).

Sounds like a fun project. Wanna switch jobs? :)


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.