iconv fuction in C-program returns EINVAL error



Help for C/C++ for MVS, OS/390 C/C++, z/OS C/C++ and C/C++ Productivity Tools for OS/390

iconv fuction in C-program returns EINVAL error

Postby kjesse » Tue Sep 21, 2010 10:09 pm

Hi!

I have compiled a C-program on z/os using the "iconv" function for UTF-8 to ASCII conversion. The program is compiled and linked to iconv. But when I run the program and invoke the iconv_open("IBM-367","UTF-8") I am getting an EINVAL error ("conversion is not supported"). The program runs also on Windows and Linux. What am I doing wrong with the parameters?

Regards

Klemens
kjesse
 
Posts: 13
Joined: Tue Sep 21, 2010 9:26 pm
Has thanked: 0 time
Been thanked: 0 time

Re: iconv fuction in C-program returns EINVAL error

Postby Robert Sample » Tue Sep 21, 2010 11:01 pm

Find a copy of the XL C/C++ Programming Guide manual and check appendix E Charmap files supplied with z/OS XL C/C++ and you will discover that IBM-367 is not a supplied conversion file, hence the message you got. When I use iconv to convert to / from ASCII, I use ISO8859-1 as the charmap.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: iconv fuction in C-program returns EINVAL error

Postby kjesse » Tue Sep 21, 2010 11:45 pm

Thank you for your hint. But I tried also to convert "UTF-8" to "IBM-273" (EBCDIC) and got the same error. I tried additionaly to add "//IGNORE//TRANSLIT" (as under Unix), but there returned the EINVAL error.
kjesse
 
Posts: 13
Joined: Tue Sep 21, 2010 9:26 pm
Has thanked: 0 time
Been thanked: 0 time

Re: iconv fuction in C-program returns EINVAL error

Postby Robert Sample » Wed Sep 22, 2010 3:03 am

All I can suggest is work with your site support group to determine what the problem is and how to fix it.

And you need to be aware that while z/OS Unix System Services looks like Unix, there are many ways it does not act like Unix. So the mere fact that "something" works under Unix has absolutely no meaning or correlation for Unix System Services -- the corresponding feature may work, may not work, or may require (possibly extensive) updating to make it work.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: iconv fuction in C-program returns EINVAL error

Postby kjesse » Wed Sep 22, 2010 1:12 pm

I have another question. How can I handle characters on z/os that cannot be converted? Does the program stop? Can I ignore or translit these characters? Under Unix I can say //IGNORE or //TRANSLIT as an option. Is this possible also with the mainframe?
kjesse
 
Posts: 13
Joined: Tue Sep 21, 2010 9:26 pm
Has thanked: 0 time
Been thanked: 0 time

Re: iconv fuction in C-program returns EINVAL error

Postby Robert Sample » Wed Sep 22, 2010 4:59 pm

If you do not have the IBM web site link for the XL C/C++ library bookmarked in your browser, I strongly suggest you do so -- NOW!. It is obvious that you need to spend several days reading the manuals in this library to understand the differences between z/OS C/C++ and whatever variant you are used to using. From the XL C/C++ Run-Time Library Reference manual, section 3.408 on iconv:
If a sequence of input bytes does not form a valid character in the specified encoded character set, conversion stops after the previous successfully converted character, and iconv() sets errno to EILSEQ. If the input buffer ends with an incomplete character or shift sequence, conversion stops after the previous successfully converted bytes, and iconv() sets errno to EINVAL. If the output buffer is not large enough to hold the entire converted input, conversion stops just before the input bytes that would cause the output buffer to overflow.

For just one example, you mentioned //TRANSLIT in your earlier post. There is not a single reference to TRANSLIT in either the XL C/C++ or Unix System Services bookshelves -- which is a pretty good sign that there's no such thing on the mainframe (at least in Unix System Services). The double forward slash is used for other purposes on the mainframe, so it would be extremely rare to see those characters used for a flag.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to C, C++

 


  • Related topics
    Replies
    Views
    Last post