C#编码转换
2021-01-23 17:14
标签:returns summary 字符 ram byte encoding 声明 ret utf8 /// C#编码转换 标签:returns summary 字符 ram byte encoding 声明 ret utf8 原文地址:https://www.cnblogs.com/LCLBook/p/12073836.html
/// GB2312转换成UTF8
///
///
///
public static string gb2312_utf8(string text)
{
//声明字符集
System.Text.Encoding utf8, gb2312;
//gb2312
gb2312 = System.Text.Encoding.GetEncoding("gb2312");
//utf8
utf8 = System.Text.Encoding.GetEncoding("utf-8");
byte[] gb;
gb = gb2312.GetBytes(text);
gb = System.Text.Encoding.Convert(gb2312, utf8, gb);
//返回转换后的字符
return utf8.GetString(gb);
} ///
上一篇:(良心篇)给你们分享一篇关于C#大文件上传的整个过程
下一篇:C#中类的修饰符