c# Encoding.GetEncoding
Encoding.GetEncoding 是 C# 中的一个方法,它用于获取特定名称的编码的 Encoding 对象。如果指定的编码名称不存在,则会抛出 ArgumentException。
获取 UTF-8 编码:
Encoding encoding = Encoding.GetEncoding(“utf-8”);
获取 ASCII 编码:
Encoding encoding = Encoding.GetEncoding(“us-ascii”);
获取 Windows-1252 编码:
Encoding encoding = Encoding.GetEncoding(“windows-1252”);
获取 ISO-8859-1 编码:
Encoding encoding = Encoding.GetEncoding(“iso-8859-1”);
获取 GB2312 编码:
Encoding encoding = Encoding.GetEncoding(“gb2312”);
获取 GBK 编码:
Encoding encoding = Encoding.GetEncoding(“gbk”);
获取 Big5 编码:
Encoding encoding = Encoding.GetEncoding(“big5”);
获取 Shift_JIS 编码:
Encoding encoding = Encoding.GetEncoding(“shift_jis”);
获取 Euc-kr 编码:
Encoding encoding = Encoding.GetEncoding(“euc-kr”);
获取 KOI8-R 编码:
Encoding encoding = Encoding.GetEncoding(“koi8-r”);
链接