有人能给我解释一下Encoding.Unicode.GetBytes(“hello”)吗?

有人能给我解释一下Encoding.Unicode.GetBytes(“hello”)吗?,unicode,Unicode,我的代码: string input1; input1 = Console.ReadLine(); Console.WriteLine("byte output"); byte[] bInput1 = Encoding.Unicode.GetBytes(input1); for (int x = 0; x < bInput1.Length; x++) Console.Write

我的代码:

        string input1;

        input1 = Console.ReadLine();

        Console.WriteLine("byte output");

        byte[] bInput1 = Encoding.Unicode.GetBytes(input1);


        for (int x = 0; x < bInput1.Length; x++)
            Console.WriteLine("{0} = {1}", x, bInput1[x]);
字符串输入1;
input1=Console.ReadLine();
控制台写入线(“字节输出”);
byte[]bInput1=Encoding.Unicode.GetBytes(input1);
对于(int x=0;x
产出:

104 0 101 0 108 0 108 0 111 0

输入“hello”

有没有关于字符映射的参考,我可以从中理解这一点?

您应该在下面阅读“每个软件开发人员绝对、绝对必须了解Unicode和字符集的最低要求(没有借口!)”

您可以在中找到所有Unicode字符的列表,但不要指望在没有了解大量文本编码问题的情况下就能够读取其中的文件。

在中,您可以找到所有Unicode代码图表。显示“h”的代码点为U+0068。(查看此数据的另一个好工具是。)

有关UTF-16编码的详细信息,请访问和。简言之,U+0068编码(在UTF-16LE中)为0x68 0x00。在十进制中,这是您看到的前两个字节:104 0

其他字符的编码方式类似

最后,除了本身之外,还有一个很好的参考(当试图理解各种Unicode规范时)是