Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unicode message

Status
Not open for further replies.

AndersPG

Programmer
Apr 3, 2002
3
SE
Hi,

I am trying to get a unicode message from a queue. I am using C++ and the C++ classes for MQSeries.

I have followed the samples from IBM, where they use char* as buffer to get the message from the queue. My problem is: unicode uses 2 bytes and the second byte is most of the time zero, which means null for the char*-buffer. When the read method reaches a null it stops reading and the size of the buffer is 1 char or so. I have tryied to use a wchar_t buffer, but then I got a compiler error.

So, the question is, does any one know how to read a unicode message from a queue?

Best regards, Anders

 
I havent done this myself. But i think the message in its completeness would be got into the buffer you asked it to. Its the app's responsibility to read it properly off that buffer. So, i guess, check the appropriate read method to read this message off the buffer.

You could as well make this simple(exclude MQ) and post it in C++ thread.

Hope it helps.



Cheers
KK
 
I am just inquisitive so asking this question. What value does the dataLength property of your message hold? If this is 1 then we have a problem.

How are you reading the message. I mean if you use MQFMT_STRING then there might be a problem. But if the dataLength property gives you correct length, then you could use the dataPointer and step through the message by incrementing this pointer. This could be read into a char* or void* buffer. Then depending on the platform you are working on, use appropriate APIs for converting this to Unicode. If it is on WinNT/2K you have got a host of choices for conversions also.

In case you already have a way of solving the original problem, please let that be known.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top