Author |
Message
|
ThomasT |
Posted: Sun Apr 23, 2006 6:02 am Post subject: Codepage trouble JMSTextmessage |
|
|
Novice
Joined: 23 Apr 2006 Posts: 12
|
Hallo!
I have the following problem:
I receive a JMS message (MQSeries) with encoded with Codepage 850.
My Client receives/converts this to Cp1252.
In the JMSTextMessage there's an protected field saying "Cp850".
It would be problematic and dirty, but not impossible to have access to this protected field. BUT:
Another messsage is created from another system and there the copepage field says "UTF-8" and its not UTF-8 but (I think) Cp1252 as well. (maybe an other Cp).
So I have no change when I call in JAVA
String s = message.getText();
to receive the correct convertet text.
getText() seems to make in implizit conversion of the message bytes by calling new String(messagebytes, CODEPAGE) without any correlation to the Codepagefield in the message.
What I need are the real bytes of the message, but from a Textmessage.
The problem happend because the sender send us UTF-8. An there are trouble with german characters like äöü. The UTF-8 coding of these ChaRACTERS are not transported transperantly over this channel. All mentioned Codepages differs in the uppder bytes used by UTF-8 encoding.
I workaround would be:
String text = message.getText();
text = new String(text.getBytes(CODEPAGE), "UTF-8");
But I have no possibiliy to estimate the CODEPAGE with which the jave string was actually build. With which codepgage the messagebyte where interpreted.
I hope you understand my problem.
Greetings Thomas |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Apr 23, 2006 11:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you thought about checking into the BytesMessage method. Is there a readUTF() ?
You really have to look at how the putting application writes to the message and sets the message format.... Can you tell what the putting application does?
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
ThomasT |
Posted: Tue Apr 25, 2006 1:56 am Post subject: |
|
|
Novice
Joined: 23 Apr 2006 Posts: 12
|
fjb_saper wrote: |
Have you thought about checking into the BytesMessage method. Is there a readUTF() ?
You really have to look at how the putting application writes to the message and sets the message format.... Can you tell what the putting application does?
Enjoy  |
I tried nealy everything. But some of the methods are undocumented! (e.g. _exportBody).
I cannot say what the sender application does. I worst case, the codepage and bytes have nothing to do with each other...
getText() seems to interprete the bytes of the message, but I don't understand how. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Apr 25, 2006 3:07 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
ThomasT wrote: |
fjb_saper wrote: |
Have you thought about checking into the BytesMessage method. Is there a readUTF() ?
You really have to look at how the putting application writes to the message and sets the message format.... Can you tell what the putting application does?
Enjoy  |
I tried nealy everything. But some of the methods are undocumented! (e.g. _exportBody).
I cannot say what the sender application does. I worst case, the codepage and bytes have nothing to do with each other...
getText() seems to interprete the bytes of the message, but I don't understand how. |
Read the manuals. What JMS is doing is a get with conversion option set. As this is a Text message conversion is done from the native CCSID / Encoding of the source system to the CCSID/Encoding of the client.
In fact you need to look at the CCSID conversion tables. Encoding really applies to the least significant/most significant bit if dealing with numbers and you would not convert.
Text conversion is done via the CCSID conversion tables. If you need your text unconverted you need to look at BytesMessage and possibly ask the sending system not to set the format to MQSTR...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mvic |
Posted: Tue Apr 25, 2006 3:33 am Post subject: |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
fjb_saper wrote: |
Read the manuals. What JMS is doing is a get with conversion option set. |
Last time I looked, no conversion was done in MQ's JMS classes, except (if I remember correctly) when reading RFH or RFH2 response messages from a broker. I'm interested : where did you see (or read) that JMS does conversion? |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Apr 26, 2006 2:29 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
mvic wrote: |
fjb_saper wrote: |
Read the manuals. What JMS is doing is a get with conversion option set. |
Last time I looked, no conversion was done in MQ's JMS classes, except (if I remember correctly) when reading RFH or RFH2 response messages from a broker. I'm interested : where did you see (or read) that JMS does conversion? |
Check out the TextMessage Class.
The conversion is done for you behind the scenes because
Code: |
String mytext = txtmsg.getText(); |
returns a readable string.
On some calls (depending on client CCSID, server CCSID, message CCSID you may get a JMSException that boils down to a "could not convert"....
Enjoy _________________ MQ & Broker admin |
|
Back to top |
|
 |
|