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是一个程序员常用的小工具合集,有个比较友好的交互界面.主要包含编码转换,时间戳转换 ...
随机推荐
- 多张表进行关联查询---->删除某个数据的时候出现还有子记录的提示
多张表进行关联查询的时候,当某张表里面的一个字段在另外一张表有定义,就相当于一张表是另外一张表的子表:比如现在开发所遇到的一个问题: 这个是在删除sys_user表的里面的数据的时候出现的问题,因为s ...
- centos6 编译安装nodejs4.3
官网下载源码包 https://nodejs.org/en/download/ source code #下载 wget https://nodejs.org/dist/v4.3.2/node-v4. ...
- XMPP Authentication
From: http://www.ietf.org/rfc/rfc2831.txt 2 Authentication The following sections describe how to ...
- sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
使用root 登录,然后执行: chown root:root /usr/bin/sudo chmod 4755 /usr/bin/sudo reboot
- 动态树Link-cut tree(LCT)总结
动态树是个好玩的东西 LCT题集 预备知识 Splay 树链剖分(好像关系并不大) 动态树(Link-cut tree) 先搬dalao博客 什么是LCT? 动态树是一类要求维护森林的连通性的题的总称 ...
- JavaScript对象基础知识总结
1.什么叫JavaScript对象? 定义:名值对的集合.简单的讲就是容纳属性值和属性值的容器,这些属性可以是无序的,基本上JavaScript中所有的事物都可以看成对象. 拓展:我们经常说,数组也是 ...
- mysql for mac 上的安装及用DataGrip连接
---恢复内容开始--- 1.首先下载MySQL的mac版本,地址百度就行了. 2.这个时候需要注意安装的时候,弹出来的一个类似窗口,上面有提示默认密码,但是我当时就忘记了这个默认密码,如果你记住了默 ...
- 用matplotlib绘制图像
实例一: import numpy as np import matplotlib.pyplot as plt x=np.linspace(0,6,100) y=np.cos(2*np.pi*x)*n ...
- JS框架设计之加载器所在路径的探知一模块加载系统
1.要加载一个模块,我们需要一个URL作为加载地址,一个script作为加载媒介,但用户在require是都用ID,我们需要一个将ID转换为URL的方法,思路很简单,强加个约定,URL的合成规则是为: ...
- 我的Python升级打怪之路【一】:python的简单认识
Python的简介 Python与其他语言的对比: C和Python.Java.C# C语言:代码直接编译成了机器码,在处理器上直接执行 Python.Java.C#:编译得到相应的字节码,虚拟机执行 ...