MQ操作的时候遇到的头文件多两个乱码的问题
使用MQClient连接MQServer ,在放入消息的时候遇到头部多了两个乱码 “3? 05SERVERID ”这是什么原因啊。在 mqMessage.WriteUTF(utfinfo);这个动作之前我保存下来的文档看是没有这个3?的
用mqMessage.WriteUTF(utfinfo);后MQServer中就多了这两个东西。
怎么回事呢。
另外,utfinfo这个字符串在之前故意做了一次编码转换
string gb2312info = msg.ToString();
string utfinfo = string.Empty;
Encoding utf8 = Encoding.UTF8;
Encoding gb2312 = Encoding.GetEncoding("gb2312");
// Convert the string into a byte[].
byte[] unicodeBytes = gb2312.GetBytes(gb2312info );
// Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(gb2312,utf8, unicodeBytes);
// Convert the new byte[] into a char[] and then into a string.
// This is a slightly different approach to converting to illustrate
// the use of GetCharCount/GetChars.
char[] asciiChars = new char[utf8 .GetCharCount(asciiBytes, 0, asciiBytes.Length)];
utf8 .GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
utfinfo = new string(asciiChars);
谁能给我解释一下啊。急死了 --------------------编程问答-------------------- 没人啊,顶起来,大家快帮帮忙
--------------------编程问答-------------------- 帮不上忙。。帮你顶。。
补充:.NET技术 , C#