惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
酷 壳 – CoolShell
酷 壳 – CoolShell
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
美团技术团队
量子位
M
MIT News - Artificial intelligence
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
腾讯CDC
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
小众软件
小众软件
博客园 - 司徒正美
罗磊的独立博客
云风的 BLOG
云风的 BLOG
B
Blog RSS Feed
博客园 - 聂微东

博客园 - 码 头

实测有效:Win11右键默认显示更多设置教程 netcore 并发锁 多线程中使用SemaphoreSlim HTML转义字符大全 .Net Core后台任务启停(BackgroundService) 常见的JavaScript的循环处理数据方法 Linux下.NET Core进程守护设置,解决SSH关闭后.NET Core服务无法访问的问题 记录 IIS 部署vue 项目步骤 AspNetCoreApi 跨域处理(CORS ) .NET CORE 使用Session报错:Session has not been configured for this application or request 小豆苗疫苗辅助搜索 日期函数(sql) 图片javascript缩小 c# DESEncrypt 加密、解密算法 二分法算法 MVC拦截器记录操作用户日志 最全的Resharper快捷键汇总 如何将数据库中的表导入到PowerDesigner中 修复IE9.0下PlaceHolder 属性问题js脚本 sql脚本查询日期时间段日期
汉字编码问题转换
码 头 · 2016-07-15 · via 博客园 - 码 头
using System;
class DistrictCode
{
	public static void Main(string[] args)
	{
		while(true)
		{
			Console.Write("请输入(输入“E”退出):");
			string inputString =Console.ReadLine();
			if(iSnputString=="e"||inputString=="E")
			{
				break;
			}
			else
			{
				Console.WriteLine(TextTOQwm(inputString));
			}
		}
	}
	public static string TextTOQwm(string character)
	{
		string coding="";
		int i1=0;
		int i2=0;
		int i3=0;
		for(int i=0;i<character.Length;i++)
		{
			byte [] bytes=System.Text.Encoding.Default.GetBytes(character.Substring(i,1));
			i1=(short)(bytes[0]);
			if(bytes.Length!=1)
			{
				i2=(short)(bytes[1]);
				i3=1;
			}
			else
			{
				i2=65536;
				i3=-1;
			}
			int chrasc=i1*256+i2-65536;
			if(chrasc>0 && chrasc<160)
			{
				Console.WriteLine("只能输入汉字");
			}
			else
			{
				if(i3==-1)
				{
					Console.WriteLine("只能输入汉字");
				}
				else
				{
					string lowCode=System.Convert.ToString(Math.Abs
					(Convert.ToInt32(System.Convert.ToString(bytes[0]))-160));
					if(lowCode.Length==1)
					{
						lowCode="0"+lowCode;
					}
					string hightCode=System.Convert.ToString(Math.Abs
					(Convert.ToInt32(System.Convert.ToString(bytes[1]))-160));
					if(hightCode.Length==1)
					{
						hightCode="0"+hightCode;
					}
					coding+=character.Substring(i,1)+(lowCode+hightCode);
				}
			}
		}
		return coding;
	}
}