首页
VS Code教程
(current)
VS Code插件
(current)
VS Code打造IDE
(current)
VScode更新日志
(current)
关于
Unicode中文转码函数代码
468
人浏览 /
0
人评论
实在搞不懂TX,用户名的编码竟然返回的值不一样,如 "雷磊52D",就有如下两种返回?雷磊?52D 和 %01%u96F7%u78CA%0152D。相当的郁闷啊。好在TX还有返回中文名字,就省去的解码的过程,但还是记录下。
复制代码
代码如下:
///
/// Unicode字符转换为中文字符,如96F7,78CA等"
///
private char UnicodeToChineseByHex(string Unicode)
{
return (char)int.Parse(Unicode, System.Globalization.NumberStyles.HexNumber);
}
///
/// Unicode字符转换为中文字符,如96F7,78CA等
/// 注意:解码从后向前的
///
private string UnicodeToChinese(string Unicode)
{
byte[] array = new byte[Unicode.Length / 2];
for (int i = 0; i < array.Length; i++)
{
string s1 = Unicode.Substring(Unicode.Length - (i + 1) * 2, 2);
int t1 = Convert.ToInt32(s1, 16);
array[i] = (byte)t1;
}
return System.Text.Encoding.Unicode.GetString(array);
}
///
/// 中文字符转换为Unicode字符,如'雷'等
///
private string ChineseToUnicode(char Chinese)
{
return ((int)Chinese).ToString("x");
}
您可能感兴趣的文章:
PHP gbk环境下json_dencode传送来的汉字
js中encode、decode的应用说明
php中json_decode()和json_encode()的使用方法
在asp中使用js的encodeURIComponent方法
php urlencode()与urldecode()函数字符编码原理详解
php json_encode奇怪问题说明
PHP5.4中json_encode中文转码的变化小结
相关文章
如何有效避免设计作品“空”?
高点击率钻展,设计环节…
无敌配色技巧(一)
留言
全部评论
晴天下起了小雨
2017-10-01 18:00
很喜欢,果断关注了
回复
wjmyly7336064
2017-10-01 18:00
相当实用,赞美了
橘大佬
2017-10-01 18:00
就是有些细节再到位点就好了…
回复
微信公众号
关注微信公众号获取更多VSCode编程信息,定时发布干货文章
最新文章
What's the make money?
MySQL 9.0 的新增功能
Apple 在 iOS 17 中使用 Swift 和 SwiftUI
编写更多“无用”软件
windows 修改环境变量后在 vscode 的终端不生效的两种解决方法
整理列出PHP各个版本5.2至8.0、8.1的特性以及区别
unicode 表情对照表
Stable Diffusion(AI绘画)Lora模型BRA V4发布:AI生成东亚人照片的生态可能因此改变
热门标签
VSCode
python
php
插件
防火墙
nodejs
远程开发
linux
virtualenv
flutter
安卓
苹果
图标主题
mysql
VScode插件
全部评论