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

> Now, the return value #RC is not defined in the example. According to the
> IBM documentation it should be of type size_t (unsigned int) but many
> examples I've seen have a return value set a int.

The problem is, iconv() returns -1 when an error occurs.  That may seem
normal, until you factor in the fact that an unsigned number CANNOT be
negative.

If you look at the bits that are used to represent an int, and the bits
that are used to represent an unsigned int, you'll notice that for numbers
0 - 2147483647 they are identical.  The only difference occurs when you go
above that number.   Therefore, an int value and an unsigned int value are
interchangable unless the string you're translating is 2gb long or larger.

In most cases, it's just easier for the RPG programmer to use 10I 0 so
they can compare it with -1 (since RPG doesn't have casting, you can't
cast -1 to size_t like you can in C)

> Also, the third and fifth variables point to the addresses of int
> datatypes. The IBM documentation specifies that the fields should be of
> type size_t (unsigned int).

It probably wouldn't hurt to change your prototype for these parameters to
10U 0 -- but again, unless your string is over 2gb long, it won't matter.

> So, on balance, this example doesn't really help - it generates more
> questions for me than answers. Basically, I'm at  the point where I think
> the example should never ever work, and I'd probably cry if I used it and it
> worked, because then it would mean that "I just don't get it". I'm not sure
> what's worse - code that's not up to it or a coder that's not up to it. :-)
>
> Should the example work? If so, what am I missing here?

I didn't look at the example that buck's pointing you at, but I imagine
that it works.  Maybe you're just not very familiar with two's complement
integers?


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.