Author |
Message
|
Bartez75 |
Posted: Fri Jan 12, 2007 6:59 am Post subject: Problem with putting message on queue in .net application c# |
|
|
 Voyager
Joined: 26 Oct 2006 Posts: 80 Location: Poland, Wroclaw
|
Hi
I'm putting a test message "Hello again" on queue with the C# code in below.
Then on queue message looks like that:
H.e.l.l.o. .a.g.a.i.n.
and together with hex:
00000000 H.e.l.l. o. .a.g. 48006500 6C006C00 6F002000 61006700
00000016 a.i.n. 61006900 6E00
What to set to make it look more like "Hello again".
thanks for any help.
Code: |
public void PutMsgOnQueue(string msg, string queueName)
{ {
string mText;
try
{
mqQueue = mqQMgr.AccessQueue( queueName,
MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING );
}
catch (MQException mqe)
{
mText = mqrcText.getMQRCText(mqe.Reason);
MessageBox.Show(mText);
return;
}
mqMsg = new MQMessage();
mqMsg.WriteString(msg);
mqMsg.Format = MQC.MQFMT_STRING;
mqMsg.CharacterSet=1208;
mqPutMsgOpts = new MQPutMessageOptions();
try
{
mqQueue.Put( mqMsg, mqPutMsgOpts );
}
catch (MQException mqe)
{
mText = mqrcText.getMQRCText(mqe.Reason);
MessageBox.Show(mText);
return;
}
mqQueue.Close();
}
|
|
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jan 12, 2007 7:27 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Strings in .NET are Unicode.
That means that they use two bytes for each character. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Bartez75 |
Posted: Tue Jan 16, 2007 7:59 am Post subject: |
|
|
 Voyager
Joined: 26 Oct 2006 Posts: 80 Location: Poland, Wroclaw
|
Defult value for CharacterSet is 1200. With this value message "Hello again" looks ok and when I get it from a queue then I get "Hello again".
I set CharacterSet = 1208 and put message on the queue with that value. After that I did a GET and the message from the queue is only "H".
Put and Get I do with API from amqmdnet.dll |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 16, 2007 8:02 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
Vitor |
Posted: Tue Jan 16, 2007 8:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Search the forum for some useful posts on character sets, which are Unicode, which are not, and the simple beauty of "convert on get".
Or try the various manuals on the subject.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Bartez75 |
Posted: Wed Jan 31, 2007 3:45 am Post subject: |
|
|
 Voyager
Joined: 26 Oct 2006 Posts: 80 Location: Poland, Wroclaw
|
Hi
I know what I was doing wrong.
I run mqMsg.WriteString(msg); before I set CharacterSet property. When I put mqMsg.WriteString(msg); after mqMsg.CharacterSet=1208; then it is working also with 437 and others. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jan 31, 2007 3:50 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Well done you!
Thank you for posting the outcome. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|