//load a field from a string buffer public void LoadField(string strData) { if (strData == null) { throw new ArgumentNullException(); } int colonIndex = strData.IndexOf(':'); if (colonIndex != -1) { m_strName = strData.Substring(0, colonIndex); } else { m_strName = ""; } colonIndex++; m_strValue = strData.Substring(colonIndex, strData.Length - colonIndex).Trim(); //need decode!!! and m_strCharset MimeCode aFieldCode = MimeCodeManager.Instance.GetCode(GetName()); if (aFieldCode != null) { m_strValue = aFieldCode.DecodeToString(m_strValue); m_strCharset = aFieldCode.Charset; } }
public override string DecodeToString(string s) { string dString = ""; int start = 0; while (start < s.Length) { int i = s.IndexOf("=?", start); if (i != -1) { dString += s.Substring(start, i - start); int j = s.IndexOf("?=", i + 2); if (j != -1) { i += 2; int k = s.IndexOf('?', i); if (k != -1 && s[k + 2] == '?') { Charset = s.Substring(i, k - i); string decString = s.Substring(k + 3, j - k - 3); if (s[k + 1] == 'Q') { MimeCode aCode = MimeCodeManager.Instance.GetCode("quoted-printable"); aCode.Charset = Charset; dString += aCode.DecodeToString(decString); } else if (s[k + 1] == 'B') { MimeCode aCode = MimeCodeManager.Instance.GetCode("base64"); aCode.Charset = Charset; dString += aCode.DecodeToString(decString); } else { dString += decString; } } else { dString += s.Substring(k, j - k); } start = j + 2; } else { dString += s.Substring(i, s.Length - i); break; } } else { dString += s.Substring(start, s.Length - start); break; } } return(dString); }
public string GetText() { string encoding = GetTransferEncoding(); if (encoding == null) { encoding = MimeConst.Encoding7Bit; } MimeCode aCode = MimeCodeManager.Instance.GetCode(encoding); aCode.Charset = GetCharset(); return(aCode.DecodeToString(mContent)); }