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

推荐订阅源

N
Netflix TechBlog - Medium
I
InfoQ
Engineering at Meta
Engineering at Meta
Jina AI
Jina AI
Recent Announcements
Recent Announcements
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Docker
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
博客园 - Franky
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog RSS Feed
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
月光博客
月光博客
罗磊的独立博客

博客园 - skyfei

Xcode 文档注释方法 查看iOS模拟器应用的沙箱文件 Show in Finder OC代码 C# x86应用x64系统上读取x64位应用的注册表 Make webclient support upload the large file which are larger than 1G Shortcut key for WPF get Android information with adb, the build version Decodes a QuotedPrintable encoded string C# USB Detection - winform and WPF [转] 线程同步 C# 常见面试题(2) 转:C# Interview Questions Openxml: 导出excel 设置 cell的格式 - skyfei OpenXML: excel 插入BarChart图表 OpenXML: Asp.net利用OpenXML 导出Excel. TRIGGERS :Cannot use text, ntext, or image columns in the 'inserted' and ' deleted' tables. 'String or binary data would be truncated' error message .net Create Excel 2007 file with open xml 利用.Net Framework2.0 zip压缩、解压 string 数据
C#中文和UNICODE字符转换方法 - skyfei - 博客园
skyfei · 2008-08-01 · via 博客园 - skyfei

 转自百度博客: http://hi.baidu.com/zzticzh/blog/item/0ffbdd8856b92890a5c2722d.html

没想到百度也有这么专业的博主   

//中文转为UNICODE字符

string str = "中文";
            string outStr = "";
            if (!string.IsNullOrEmpty(str))
            {               
                for (int i = 0; i < str.Length; i++)
                {
                    //将中文字符转为10进制整数,然后转为16进制unicode字符
                    outStr += "http://www.cnblogs.com/skyfei/admin/file://u/" + ((int)str[i]).ToString("x");
                }
            }

//UNICODE字符转为中文

            string str = "http://www.cnblogs.com/skyfei/admin/file://u4e2d//u6587";
            string outStr = "";
            if (!string.IsNullOrEmpty(str))
            {
                string[] strlist = str.Replace("http://www.cnblogs.com/skyfei/admin/file://%22,%22%22).split(%20u%20/);
                try
                {
                    for (int i = 1; i < strlist.Length; i++)
                    {
                        //将unicode字符转为10进制整数,然后转为char中文字符
                        outStr += (char)int.Parse(strlist[i], System.Globalization.NumberStyles.HexNumber);
                    }
                }
                catch (FormatException ex)
                {
                    outStr = ex.Message;
                }
            }