小编Err*_*eak的帖子

Unicode的位串

我有一串比特,像这样string str = "0111001101101000"是字母"sh".
我需要用它来制作Unicode字母.我正在做以下事情:

BitArray bn = new BitArray(str.Length); //creating new bitarray
for (int kat = 0; kat < str.Length; kat++)
{
    if (str[kat].ToString() == "0")//adding boolean values into array
    {
        bn[kat] = false;
    }
    else
        bn[kat] = true;
}

byte[] bytes = new byte[bn.Length];//converting to bytes
bn.CopyTo(bytes, 0);
string output = Encoding.Unicode.GetString(bytes); //encoding                          

textBox2.Text = output; // result in textbox
Run Code Online (Sandbox Code Playgroud)

但输出文本只是完全混乱.怎么做对了?

c# string unicode bits

0
推荐指数
1
解决办法
113
查看次数

标签 统计

bits ×1

c# ×1

string ×1

unicode ×1