|
- asp小知识——UTF-8编码转GBK
- 作为基础小知识,网上很多就直接复制了!
- /// <summary>
- /// 编码的代码
- /// </summary>
- /// <param name="value">需要转换的字符串</param>
- /// <returns>返回转换后的字符串</returns>
- public string EnCodeCovert(string value)
- {
- System.Text.Encoding srcEncode = System.Text.Encoding.GetEncoding("utf-8");
- System.Text.Encoding convToEncode = System.Text.Encoding.GetEncoding("GBK");
- byte[] bytes = srcEncode.GetBytes(value);
- System.Text.Encoding.Convert(srcEncode, convToEncode, bytes, 0, bytes.Length);
- return convToEncode.GetString(bytes);
- }
复制代码
|
|