using System;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
string str = Console.ReadLine();
char chinese = str[0];
byte[] bytC = Encoding.GetEncoding("gb2312").GetBytes(new char[] { chinese });
int i = (int)bytC[0] << 8;
i += (int)bytC[1];
Console.WriteLine(i);
}
catch
{
Console.WriteLine("你输入的不是汉字");
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
利用位移运算符获取汉字的编码值
最新推荐文章于 2023-12-28 12:28:19 发布