Operating System - OpenVMS
1753837 Members
9222 Online
108806 Solutions
New Discussion юеВ

Re: ICONV returns empty output buffer

 
rakesh patel
Occasional Advisor

ICONV returns empty output buffer

Hello,
I have another question. I'm probably doing something stupid but...
I have the internationalization kit installed, so I have all the .ICONV files.
I'm reading a UTF-8 encoded message, which I try to converted using iconv.

However the output buffer after calling iconv contains nothing, but the inbytesleft is 0, so all characters should have been converted.

Regards
Rakesh
8 REPLIES 8
Robert Gezelter
Honored Contributor

Re: ICONV returns empty output buffer

Rakesh,

Most likely, the code has an error. Without the code, any comments would be pure random speculation.

Please post a code segment that reproduces the problem that you are encountering. Before posting the code segment, please verify that the code segment is complete (e.g., it compiles, links, and produces the reported problem when executed).

- Bob Gezelter, http://www.rlgsc.com
Hoff
Honored Contributor

Re: ICONV returns empty output buffer

To expand on Bob's comments, I'd suggest first creating and testing something with the default encoding, and then work your way up to your own conversions.

It took a couple of reads through the C environment to get the hang of wide characters and UTC stuff.

I'd expect there are examples of using these calls available. And there are ports of libiconv available from various sources, as well.

Here's an earlier discussion:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=726740

There are also ports of libxml2 around, and xml can help deal with file structuring and "weird" data.

rakesh patel
Occasional Advisor

Re: ICONV returns empty output buffer

Hello,
I'm reading a message from MQ queue. The message is an UTF-8 xml message.

I have the following...
Call iconv_open
iconv_struct = iconv_open("ISO8859-1", "UTF-8");

Then I have my input message from MQ
char *input

size_t len = strlen(input);
char* outbuf = calloc(sizeof(char),len*2);
size_t outlen = len*2;

if(iconv(iconv_struct,&input,&len,&outbuf,&outlen) != 0)
{
printf("error\n");
}
else
{
printf("Success\n");
printf("[%s]\n",outbuf);
}
Hoff
Honored Contributor

Re: ICONV returns empty output buffer

UTF-8 XML?

I'd probably use libxml2 to read and process it. There's a port of libxml2 on the Freeware distro; it's the version that was current with the Freeware V8 distro.

There's certainly more information here, but still not enough to go on. In particular, we're going to need a little data, and it would be best to attach a text file (mumble.txt) to a reply here, with a full standalone example of your failing C code and a line or two of the UTF-8 text you're working with.

The other option is to call in some help with this sort of thing, as I'm guessing you're on a schedule to get this done.

Stephen Hoffman
HoffmanLabs.com
rakesh patel
Occasional Advisor

Re: ICONV returns empty output buffer

thanks for you help.
I'll try and get a simple example application done for monday. I'll also attach a file created from the UTF-8 message written by MQ.

I also look into lib2xml
thanks again

Rakesh
rakesh patel
Occasional Advisor

Re: ICONV returns empty output buffer

Hellom
I've tried using lib2xml and I still get an empty output buffer.

Attached is an example program source and a test file to decode.
rakesh patel
Occasional Advisor

Re: ICONV returns empty output buffer

Here's the UTF-8 file
rakesh patel
Occasional Advisor

Re: ICONV returns empty output buffer

I got lib2xml working. I made a stupid mistake in the program.