|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Double byte data |
« View previous topic :: View next topic » |
Author |
Message
|
podowd |
Posted: Fri Dec 09, 2005 2:45 pm Post subject: Double byte data |
|
|
Novice
Joined: 23 Sep 2004 Posts: 19
|
Hi,
I have a java routine thats writes an MQRFH2 message to a queue, it works fine with ASCII data, I am trying to get it to work with 'unicode'.
I set the mqmd ccsid as follows:
mBuf.characterSet = 1208; //utf-8 i think
I set the ccsid within the RFH2 header as follows:
mBuf.setDataOffset(16);
mBuf.writeInt4(1208); //utf-8 i think
I then write some double byte data:
String unicodeData = "\u65e5\u672c\u8a9e\u6587\u5b57\u5217";
mBuf.writeString(unicodeData); //Japanese Text
When I view the 'unicode' data through mq explorer (this is on windows), I see:
64 65 2F 3E 3C 2F 75 73 de/></us
72 3E 20 20 E6 97 A5 E6 r> æ.¥æ //the 20 20 pads the <usr> folder
9C AC E8 AA 9E E6 96 87 .¬èª.æ..
E5 AD 97 E5 88 97 Ã¥Â.Ã¥..
Im not sure if this is what the hex for the unicode values should be, should it match the unicode string - 65 E5 67 2C etc. ?
The message is rejected by a WBI flow with what looks like a ccsid conversion error:
00001056 rt><Insert><Type>5</Type><Text>S
00001088 ET InMsgLastChr = CAST(SUBSTRING
00001120 (InputRoot.BLOB.BLOB FROM LENGTH
00001152 (InputRoot.BLOB.BLOB) FOR LENGTH
00001184 (InputRoot.BLOB.BLOB)) AS CHARAC
00001216 TER CCSID InputRoot.MQMD.CodedCh
00001248 arSetId);</Text></Insert><Recove
00001888 er.cpp</File><Line>536</Line><Fu
00001920 nction>ImbConverterCPP::internal
00001952 ToUnicode</Function><Type></Type
I dont know if the error is due to the message I am sending to the flow or a problem with the flow (all works perfect for ASCII data).
When I change the program to remove the setting of mqmd ccsid:
// mBuf.characterSet = 1208; //utf-8 i think
all the 'unicode' data on the input queue has a value of F3:
72 3E 20 20 3F 3F 3F 3F r> ????
3F 3F ??
Any help/suggestions appreciated.
Are there any links to any code/docs that shows how to use wmq for processing unicode data?
Thanks,
Pat |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Dec 09, 2005 3:58 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Read up on CCSID. Check the SEARCH button and find the accepted CCSIDs for the RFH header.
Enjoy  |
|
Back to top |
|
 |
podowd |
Posted: Wed Dec 14, 2005 5:01 pm Post subject: Double Byte - RFH2 |
|
|
Novice
Joined: 23 Sep 2004 Posts: 19
|
Hi,
By doing the following, I can now route a message from my PC through the WBI flow on Unix Hub and back to my PC (flow on Hub looks at values within <usr> folder on MQRFH2 msg to determine where it routes msg):
1) Do not set the MQMD ccsid
2) Set the ccsid within the RFH2 header to 1208 (this is UTF8)
3) Convert the XML payload that I write after the RFH2 header to UTF-8 using getBytes("UTF8") on the String class.
4) Write the message to the queue using the MQMessage write(byte[]) method, writing the byte[] returned by String getBytes("UTF8")
When I take the message returned by the Hub off the queue, the only way
I seem to be able to correctly process the XML data (the data after the RFH2 header in my case) is using:
byte[] strBytes = new byte[dataLength]; //data after RFH2 header
for (int i = 0; i < dataLength; i++) {
strBytes[i] = rawMQMessage.readByte();
}
String utf8msg = new String(strBytes, "UTF-8");
When I write utf8msg to a UTF-8 file, the data looks good (The Japanese characters display correcly, the variable utf8msg displays correctly in Eclipse also).
Looking at the manuals, there are other methods such as readLine on MQMessage class that seemingly do data conversion. Do they work off the MQMD ccsid rather than the ccsid in the RFH2 header? (I suspect they do as my data gets garbled when I use these methods - the MQMD ccsid on my message is 819, the RFH2 ccsid is 1208, the XML message is in 1208, but WMQ must do the conversion using 819?).
Could anyone suggest a more generic/better way to convert the data that follows the RFH2 header using the ccsid within the RFH2? (or point out where I may be going wrong/mis-understanding how this works etc..)
Thanks in advance,
Pat |
|
Back to top |
|
 |
podowd |
Posted: Wed Dec 14, 2005 8:47 pm Post subject: |
|
|
Novice
Joined: 23 Sep 2004 Posts: 19
|
Hi,
I think I see what the problem is:
As the MQMD is set to 819, the readLine is doing the conversion based on this rather than the RFH2 ccsid (1208). I changed the sending program to set the ccsid on the MQMD to 1208, now when using the readLine method WMQ processes the data correctly (I no longer need to 'hardcode' UTF8).
Thanks,
Pat
 |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|