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



On 11 May 2012 06:11, Charles Wilt wrote:

I've got a user space containing ASCII data. I'm going to use
iconv() to convert the data to EBCDIC.

Do I need a separate userspace to hold the output, or can I simply
send two pointers to iconv() pointing to the same userspace so that
the data is converted in place?

I could see having problems if I was going to/from double byte <-->
single byte. But since I'm going single to single I think it will
work.

We getting ready to try it, but even if it works I want to make sure
it's allowed or recommended and we're not just getting lucky. :)

I avoid having to ask the question whether it will [now and in the future continue to] function correctly. I do so by avoiding the use of the same variable or storage\address for both the "source" and "destination" of any function\feature, unless there is explicit documentation stating the usage of the same variable or address\storage for both the source and destination is safe [within the specific context it is being used]. Lacking any documentation to support my assumption [perhaps only based on inference of effects in testing] that the feature will work as desired, I expect that at anytime the implementation using that assumption may fail. Not knowing if such a failure would be manifest as an error versus just incorrect output, the choice for me is usually pretty simple.

For the iconv(), I would submit a reader comment suggesting that documentation should state any allowances and restrictions for the same storage for both of the inbuf and outbuf pointers. With support, possibly also open a PMR; without the former however, the doc is unlikely to get changed.

I am not sure of the requirements, but the *USRSPC could be opened as a text (O_TEXTDATA) stream to effect the translation.

FWiW: Interestingly, the Open() Open File API actually seems possibly may allude to an allowance\restriction for use of the iconv() in the inquired-of manner, for use of the FIFO file mode [per O_CCSID implication]: "Any conversion between CCSIDs that are not strictly single-byte must be done by an open instance that has write only access." Not to suggest I understand the meaning of that quote, just the explicit mention of a restriction dealing with strictly SBCS and text-mode for CCSID xlate.

Regards, Chuck

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.