C#字符转之UTF8转成Unicode
来源:互联网 发布:淘宝一键复制有坏处吗 编辑:程序博客网 时间:2024/06/03 20:51
用C#写代码时,会经常用到不同编码格式之间的转换。下面代码就是将UTF8编码格式的C# String转换成Unicode编码格式的String。
仅供参考。
Encoding utf8 = Encoding.UTF8;
Encoding defaultCode = Encoding.Unicode;// Convert the string into a byte[].
byte[] utf8Bytes = utf8.GetBytes(str[0].ToString());
// Perform the conversion from one encoding to the other.
byte[] defaultBytes = Encoding.Convert(utf8, defaultCode, utf8Bytes);
char[] defaultChars = new char[defaultCode.GetCharCount(defaultBytes, 0, defaultBytes.Length)];
defaultCode.GetChars(defaultBytes, 0, defaultBytes.Length, defaultChars, 0);
string defaultString = new string(defaultChars);
0 0
- C#字符转之UTF8转成Unicode
- unicode转成UTF8
- C#把内存里的utf8字符串转成C#内部使用的Unicode
- C#中文乱码解决:UTF8 转 UNICODE
- C# unicode utf8 转码
- 字符编码转换(utf8-unicode)
- Delphi 转换 UTF8 字符为 Unicode 字符
- Unicode转UTF8
- utf8 转 unicode
- UTF8转unicode
- UNICODE 转 UTF8
- utf8转unicode
- unicode转utf8
- utf8转unicode
- utf8转unicode
- PHP UNICODE 转 UTF8
- unicode转UTF8
- unicode 转 utf8
- 第十五周 项目三 - B-树的基本操作
- 【基于WPF+OneNote+Oracle的中文图片识别系统阶段总结】之篇三:批量处理后的txt文件入库处理
- 51nod 1629 B君的圆锥(三分)
- 线性回归与贝叶斯推理——漫谈机器学习
- POJ1330 LCA/给树的节点标记层数
- C#字符转之UTF8转成Unicode
- 清除浮动的几种常用的方法
- 基于netty的心跳检测
- LeetCode 387. First Unique Character in a String
- 【矩阵相关】[Codeforces - 736D]Permutations
- APICLOUD平台初体验(一个任务系统的开发)
- linux下IO相关知识
- 报数(类似猴子选大王)
- POJ 2502 - Subway(单源最短路)