Topic
  • No replies
SystemAdmin
SystemAdmin
8523 Posts

Pinned topic MQ UTF16 -> UTF8 problems

‏2012-11-09T08:44:24Z |
Hi,
I have an application made in C#, i send xml over MQ but the reciver expect UTF8 but get UTF16 from me. What i understand I cant convert a string in C# to UTF8 it always UTF16.

Here is my code, I have tested every combination but it not working.

public void PutMessageOnQueueNEW(string message)
{
try
{
//queue = queueManager.AccessQueue(queueName, MQC.MQGMO_CONVERT + MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
queue = queueManager.AccessQueue(queueName, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
//Encoding utf8 = Encoding.UTF8;
//byte[] utfBytes = utf8.GetBytes(message);
//byte[] utf8String = Encoding.UTF8.GetBytes(message);

queueMessage = new MQMessage();
queueMessage.WriteString(message);
//queueMessage.WriteString(BitConverter.ToString(utf8String));
//queueMessage.WriteUTF(message);
//queueMessage.Format = MQC.MQFMT_STRING;
//queueMessage.Encoding = MQC.MQENC_NATIVE;
//queueMessage.CharacterSet = 1208;

queue.Put(queueMessage);
//Lagt till av FRAN19
queue.Close();
queueManager.Disconnect();
}

catch (MQException mqexp)
{
Console.WriteLine("MQSeries Exception: " + mqexp.Message);
Console.WriteLine("MQSeries Exception: " + mqexp.Reason);
Console.WriteLine("MQSeries Exception: " + mqexp.StackTrace);
}

}
Please help!
Best regards
Fredrik