byte[] bytes = Convert.FromBase64String("=?GBK?B?MjAxMtbQzuez1Mqyw7Q=?=");哪个字符无效啊,我用在线解码能解出来。
另外求完整的base64解码函数 谢谢

解决方案 »

  1.   

    去掉所有?,再去掉开头后最后的=各一个,再去掉开头的GBK,得到
    MjAxMtbQzuez1Mqyw7Q=Response.Write(Encoding.GetEncoding("gbk").GetString(Convert.FromBase64String("MjAxMtbQzuez1Mqyw7Q=")));
    输出:2012中午吃什么
      

  2.   


    +1根据这个,可以知道这个字符串是经过包装的 Base64String,其中 "=?" 表示编码头,"?=" 表示编码结尾,"GBK?" 表示编码规则,"B?" 表示 base64。
      

  3.   

    这是MIME的标示Encoded-WordSince RFC 2822, conforming message header names and values should be ASCII characters; values that contain non-ASCII data should use the MIME encoded-word syntax (RFC 2047) instead of a literal string. This syntax uses a string of ASCII characters indicating both the original character encoding (the "charset") and the content-transfer-encoding used to map the bytes of the charset into ASCII characters.
    The form is: "=?charset?encoding?encoded text?=".
    charset may be any character set registered with IANA. Typically it would be the same charset as the message body.
    encoding can be either "Q" denoting Q-encoding that is similar to the quoted-printable encoding, or "B" denoting base64 encoding.
    encoded text is the Q-encoded or base64-encoded text.来自Widipedia
    http://en.wikipedia.org/wiki/MIME
      

  4.   

    如何把上面的字符串截取成符合条件的,是每个字符串都固定用substring,还是得另写一个方法,求解
      

  5.   

    那UTFB的格式是什么样的  比如=?utf-8?B?5pyA5paw5rWL6K+V?=   
      

  6.   

    private static string MethedA(string base64)
    {
    Match match = Regex.Match(base64, @"(?<=\?)[^?]+(?=\?=)");
    return match.Value;
    }
      

  7.   

    protected void Page_Load(object sender, EventArgs e)
    {
    string code;
    string base64 = MethedA("=?GBK?B?MjAxMtbQzuez1Mqyw7Q=?=", out code);
    Response.Write(base64 + "<br/>");
    Response.Write("字符集为:" + code);
    } private static string MethedA(string base64, out string code)
    {
    Match match = Regex.Match(base64, @"=\?([^?]+)\?[bB]\?([^?]+)(?=\?=)");
    code = match.Groups[1].Value;
    return match.Groups[2].Value;
    }
    调用方法,获取标准base64字符串,以及字符集名称:
    MjAxMtbQzuez1Mqyw7Q=
    字符集为:GBK 
      

  8.   

    大哥,我GBK的没问题了 utf8解出来还是乱码 繁体字乱码 求正则表达式
      

  9.   

    你确定那个包装过的base64字符串是utf-8的?,一个字符串只对应一种字符集哦。
      

  10.   

    =?utf-8?B?57KS5a2Q?=  我已经找出来了 他是 GBK都解码出来了 只剩下UTF-8的出来全是繁体字乱码
      

  11.   

    http://topic.csdn.net/u/20111207/10/ac26e7e1-d242-4ad4-b493-94d2dcb64d83.html  这是我新开的帖子 可以去那边回答