csharp: Converting chinese character to Unicode
Function chinese2unicode(Str)
Dim Str_one:Str_one = ""
Dim Str_unicode:Str_unicode = ""
For i = 1 To Len(Str)
Str_one = Mid(Str, i, 1)
If AscW(Str_one) < 0 or AscW(Str_one) > 255 Then
Str_unicode = Str_unicode & Chr(38)
Str_unicode = Str_unicode & Chr(35)
Str_unicode = Str_unicode & Chr(120)
Str_unicode = Str_unicode & Hex(AscW(Str_one))
Str_unicode = Str_unicode & Chr(59)
Else
Str_unicode = Str_unicode & Str_one
End If
Next
chinese2unicode=Str_unicode
End Function
/// <summary>
/// %26%23x4EB2%3B%26%23x7231%3B%26%23x7684%3B%26%23x4F1A%3B%26%23x5458%3BTeresaLiu%2C%26%23x516D%3B%26%23x798F%3B%26%23x73E0%3B%26%23x5BF6%3B%26%23x6703%3B%26%23x54E1%3B%26%23x5BC6%3B%26%23x78BC%3B%26%23x4FEE%3B%26%23x6539%3B%26%23x9805%3B%26%23x901A%3B%26%23x77E5%3B%26%23xFF1A%3B%26%23x95A3%3B%26%23x4E0B%3B%26%23x5DF2%3B%26%23x6210%3B%26%23x529F%3B%26%23x66F4%3B%26%23x6539%3B%26%23x5BC6%3B%26%23x78BC%3B%26%23xFF0C%3B%26%23x5982%3B%26%23x6709%3B%26%23x67E5%3B%26%23x8A62%3B%26%23xFF0C%3B%26%23x8ACB%3B%26%23x81F4%3B%26%23x96FB%3B%26%23x9999%3B%26%23x6E2F%3B27109368%26%23xFF0F%3B%26%23x4E2D%3B%26%23x570B%3B4008846222
///塗聚文 20140724
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
private string chinese2uncode(string str)
{
string s = "";
string outStr = "";
if (!string.IsNullOrEmpty(str))
{
for (int i = 0; i < str.Length; i++)
{
if (Microsoft.VisualBasic.Strings.AscW(str[i].ToString()) < 0 || Microsoft.VisualBasic.Strings.AscW(str[i].ToString())>255) //如果是中文转换Regex.IsMatch(str[i].ToString(), @"[\u4e00-\u9fa5]")
{
//outStr += "\\u" + ((int)str[i]).ToString("x");
outStr = outStr+(char)38;// "&";//char(38);
outStr = outStr + (char)35;// "#";
outStr = outStr + (char)120;// "x";
outStr = outStr + Microsoft.VisualBasic.Conversion.Hex(Microsoft.VisualBasic.Strings.AscW(str[i].ToString())); //outStr +
outStr = outStr + (char)59;// ";";
//Str_unicode = Str_unicode & Chr(38)
//Str_unicode = Str_unicode & Chr(35)
//Str_unicode = Str_unicode & Chr(120)
//Str_unicode = Str_unicode & Hex(AscW(Str_one))
//Str_unicode = Str_unicode & Chr(59)// ; }
else
{
outStr += str[i];
} }
}
s = outStr;
return s;
}
csharp: Converting chinese character to Unicode的更多相关文章
- IEF could not decode Chinese character in IE history well
My friend is working on some case, and she looks not in the mood. I ask her what's going on. She wan ...
- EnCase v7 could not recognize Chinese character folder names / file names on Linux Platform
Last week my friend brought me an evidence file duplicated from a Linux server, which distribution i ...
- GitHub & puppeteer & Chinese character & bug
GitHub & puppeteer & Chinese character & bug https://github.com/GoogleChrome/puppeteer/b ...
- Unicode Character Table – Unicode 字符大全
Unicode(统一码.万国码.单一码)是一种在计算机上使用的字符编码.它为每种语言中的每个字符设定了统一并且唯一的二进制编码,以满足跨语言.跨平台进行文本转换.处理的要求.Unicode Chara ...
- (Android) Chinese Character
Convert Chinese strings to English strings Apply pinyin4j.jar public static class ConvertChineseToPi ...
- Multi-Byte Character Set & Unicode Character Set
本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/49592361 编程时遇到BUG:err ...
- 汉字转拼音再转ASCII
汉字能够转成拼音.能够在转成ASCII码,然后就能够转成十六进制数,再就能够转成0和1组成的二进制帧了! 比方说: 我爱你 -> wo ai ni -> 119 111 32 97 105 ...
- solr入门之pinyin4j源代码改写动态加入扩展词及整合进war项目中
1.初始化时载入用户定义的字典 package net.sourceforge.pinyin4j; import net.sourceforge.pinyin4j.multipinyin.Trie; ...
- ApkToolBoxGUI 0.0.8发布了!!
https://github.com/jiangxincode/ApkToolBoxGUI APKToolBoxGUI是一个程序员常用的小工具合集,有个比较友好的交互界面.主要包含编码转换,时间戳转换 ...
随机推荐
- 微信朋友圈评论/回复/cell/键盘谈起
微信朋友圈评论功能的细节考虑及实现 微信朋友圈回复tableview iOS 实现微信朋友圈评论回复功能(一)
- ${__BeanShell(${SCRIPT})}
通过将变量名称括在' $ { '和' } '中来引用测试元素中的变量. 函数以相同的方式引用,但按照惯例,函数名称以“ __ ” 开头,以避免与用户值名称冲突*.有些函数使用参数来配置它们,这些函数用 ...
- 大数据-zookeeper集群安装
一.安装前发现的问题: 1.安装前期发现jps权限不够 [root@master1 ~]# jps -bash: /opt/workspace/jdk1./bin/jps: Permission de ...
- Angular material mat-icon 资源参考_Places
ul,li>ol { margin-bottom: 0 } dt { font-weight: 700 } dd { margin: 0 1.5em 1.5em } img { height: ...
- MSSQL远程连接操作(转)
--遠程連接操作 /****************************************************************************************** ...
- jq扩展获取表单值、设置值
不多说,直接上代码 //jq添加插件 (function (window, $) { $.fn.serializeJson = function () { var serializeObj = {}; ...
- Duilib总体框架
从GoogleCode上下载的duilib工程中附带的一副总体设计图(如下所示),可以先整体了解一下,有个初步的认识,对后续进一步深入了解学习会很有帮助. 通过设计图有了一个初步认识后,接下来开始进一 ...
- 基于CommonKADS方法论实现知识库系统
说明:本文是Knowledge-based systems with thecommonKADS method文章的翻译. 一.知识库系统的背景 1. 什么是知识库系统(KBS) 知识库系统是人工智能 ...
- Java Service Wrapper 发布Java程序或者jar包为Windows服务
下载Windows版本:http://nchc.dl.sourceforge.net/sourceforge/wrapper/wrapper-windows-x86-32-3.2.3.zip 现在目前 ...
- WPF的布局-Grid(表格布局)
1. Grid布局就是表格布局 如下图: 2. 使用方法 2.1. 先生成适量的行和列,代码如下: <Grid><!--使用Grid控件--> <Grid.ColumnD ...