乐趣区

关于c#:C-字符串转换为指定编码集的-base64-字符串

using System;
using System.Text;

string EncodeBase64(string code_type, string code)
{
    string encode = "";
    byte[] bytes = Encoding.GetEncoding(code_type).GetBytes(code);
    try
    {encode = Convert.ToBase64String(bytes);
    }
    catch
    {encode = code;}
    return encode;
}

EncodeBase64(“utf-8”, “abc123”);

退出移动版