C# Byte[] 数组操作

byte[] Strbyte = Encoding.GetEncoding("big5").GetBytes(str);
            if (Strbyte.Length < len)
            {
                Strbyte = Encoding.GetEncoding("big5").GetBytes(str.PadRight(len, ' '));
            }
            Byte[] ThisByte = new Byte[len];
            if (Strbyte.Length > len)
            {
                Buffer.BlockCopy(Strbyte, 0, ThisByte, 0, len);
            }
            else
            {
                
                Buffer.BlockCopy(Strbyte, 0, ThisByte, 0, Strbyte.Length);
            }
            return Encoding.GetEncoding("big5").GetString(ThisByte);

posted @ 2018-01-16 18:57  LuoCore  阅读(4558)  评论(0编辑  收藏  举报