C#(.Net) 解决Informix中文乱码问题

public static string GetEncodingString(string srcString)
        {
            Encoding e8859Encode 
= Encoding.GetEncoding("iso-8859-1");
            Encoding srcEncode 
= Encoding.GetEncoding("gb2312");
            Encoding dstEncode 
= Encoding.Unicode;
            
byte[] srcBytes = e8859Encode.GetBytes(srcString);//用iso-8859-1去转换源字符串
            byte[] dstBytes = Encoding.Convert(srcEncode, dstEncode, srcBytes);//但是,是从gb2312转到unicode的
            char[] dstChars = new char[dstEncode.GetCharCount(dstBytes, 0, dstBytes.Length)];
            dstEncode.GetChars(dstBytes, 
0, dstBytes.Length, dstChars, 0);
            
return new string(dstChars);
            
        }
posted @ 2011-06-08 09:46  melody&bobo  阅读(272)  评论(0编辑  收藏  举报