最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
c# 实现获取汉字十六进制Unicode编码字符串的实例
时间:2022-06-25 07:57:22 编辑:袖梨 来源:一聚教程网
1、汉字转十六进制UNICODE编码字符串
代码如下 | 复制代码 |
/// /// //// /// /// /// publicstringCharacterToCoding(stringcharacter) { stringcoding ="";
for(inti = 0; i < character.Length; i++) { byte[] bytes = System.Text.Encoding.Unicode.GetBytes(character.Substring(i, 1));
//取出二进制编码内容 stringlowCode = System.Convert.ToString(bytes[0], 16);
//取出低字节编码内容(两位16进制) if(lowCode.Length == 1) { lowCode ="0"+ lowCode; }
stringhightCode = System.Convert.ToString(bytes[1], 16);
//取出高字节编码内容(两位16进制) if(hightCode.Length == 1) { hightCode ="0"+ hightCode; }
coding += (hightCode + lowCode);
}
returncoding; } |
2、 十六进制UNICODE编码字符串 转 汉字
代码如下 | 复制代码 |
/// /// // /// /// /// publicstringUnicodeToCharacter(stringtext) { byte[] arr = HexStringToByteArray(text);
System.Text.UnicodeEncoding converter =newSystem.Text.UnicodeEncoding();
stringstr = converter.GetString(arr);
returnstr; } |
相关文章
- 《燕云十六声》无名枪稳定上流云段位攻略 无名枪连招教学 08-09
- 锈湖根源31关星星怎么过-锈湖根源31关星星攻略 08-09
- 燕云十六声怎么结交伏禄寿-结交伏禄寿技巧 08-09
- 问剑长生新手怎么快速跟上战斗力 怎么零氪追赶战力 08-09
- 绝区零伊芙琳怎么样-绝区零伊芙琳角色介绍 08-09
- 山海奇闻2怎么快速升级-山海奇闻2快速升级方法分享 08-09