× 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.




When calling the _C_IFS_fgets external procedure in RPGLE, is the data
being read in ascii?

I'm not sure I understand this question. Are you trying to find out if the fgets() API can translate ASCII to EBCDIC? Or are you tring to find out if it'll fail when the data is not ASCII? Or what are you trying to find out?

Basically, the IFS stores the data of a file as a collection of bytes. Just one big long stream of bytes. Then, it also stores attributes of the file, such as the file's name, authorities, last change date, whether it needs to be archived, etc. One of those attributes is a CCSID that you're supposed to set to tell the system what sort of data is stored in the file. It might be a CCSID that corresponds to an ASCII character set. It might be a CCSID that corresponds to an EBCDIC character set. Or Unicode. Or whatever.

When you read the data from the file, the system is reading bytes. It's just copying data from disk to memory as a bunch of bytes.

Then, depending on the options you used when you opened the file, it'll provide other services for you, such as translating from the file's CCSID (which could be ASCII or EBCDIC or Unicode) to your job's CCSID (which is probably EBCDIC, but could be any of a number of different flavors of EBCDIC).

I don't know if that means that the file is "read in ASCII". I guess I don't know what the phrase "read in ASCII" means. OBviously, if the data in the file is in ASCII, then bytes that happen to contain ASCII values are what's read, but if the file contains non-ASCII data, then that's what ends up being read...

Also remember, the terms "ASCII", "EBCDIC" and "Unicode" only apply to human-readable text. Not all data stored in a file is text, so not everything can have the label ASCII, EBCDIC or Unicode applied to it/ (Though, text is probably the only thing you'd read with the fgets() API)


If so, does it get automatically translated into ebcdic during the read (in the RPG) or should a translate operation be performed after the read to ensure it is in ebcdic before subsequent processing?

You control that by specifying whether the file is text or binary by passing flags on the fopen() API. (_C_IFS_fopen, that is) You can also control the CCSIDs used in translation with flags you pass to the fopen() API.

Second question - can the IFS store data in ebcdic or is it always in
ascii?

Data is stored in bytes. Again, not everything fits into the catgories of EBCDIC or ASCII or Unicode. You can store any bytes you like in the IFS. If you tag the file with the appropriate CCSID, the system can help you translate it. Otherwise, you have to handle the trnaslation yourself.

You can store any bytes you want.  ASCII, EBCDIC, anything you like.


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.