c#字符串转unicode
来源:互联网 发布:电脑易教录屏软件 编辑:程序博客网 时间:2024/05/02 00:04
[DllImport("Kernel32", CharSet = CharSet.Auto)]
static extern Int32 MultiByteToWideChar(
UInt32 codePage,
UInt32 dwFlags,
[In, MarshalAs(UnmanagedType.LPStr)] String lpMultiByteStr,
Int32 cbMultiByte,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpWideCharStr,
Int32 cchWideChar);
private string ConvertToUnicode( string str, uint codepage)//utf8 to unicode
{
int l = str.Length;
int i = 0;
i = MultiByteToWideChar( codepage, 0, str, -1, null, 0);
StringBuilder wideStr = new StringBuilder(i);
i = MultiByteToWideChar( codepage, 0, str, -1, wideStr,
wideStr.Capacity);
string s = wideStr.ToString();
return s;
}
若将str(utf-8)转str1 (unicode):
string str1 = ConvertToUnicode(str, 65001);//65001 utf-8 codepage
没完全测试,不知是否有误,望指正
- c#字符串转unicode
- UNICODE字符串互转
- unicode字符串 转汉字
- UNICODE字符串互转
- Java字符串转unicode
- Java 字符串转 unicode
- C# 中字符串与Unicode相互转化
- C# 中字符串与Unicode相互转化
- C#字符串与unicode互相转换
- C#字符串与unicode互相转换
- C#字符串与unicode互相转换
- C#字符串与unicode互相转换
- c#中文转unicode
- C#中文转Unicode、Unicode转中文
- C#将Unicode的字符串转换为ANSI字符串?
- 字符串转十六进制,和Unicode
- Java把字符串转Unicode
- Python 中文转Unicode字符串
- ZOJ3209Treasure Map精确覆盖DLX
- VIM 参考手册
- ns2中广播代理实现中的问题
- ANDROID取CPU序列号
- XSS偷取密码Cookies通用脚本
- c#字符串转unicode
- 开关和灯泡的对应关系
- fscanf用于分析文件中的两个重要用法
- android系统开发--HAL层开发基础
- 写UNICODE格式的文本日志文件(UNICODE编码)
- 重庆找嵌入式方面的工作好难找哟,
- ASP.NET 主题(Themes)FAQ
- php对建立数据库表约束
- setsocket的用法