public HeaderInfo(System.Collections.Specialized.HybridDictionary headers) { this.TopLevelMediaType = new MimeTopLevelMediaType(); this.Enc = null; try { this.ContentType = MimeTools.parseHeaderFieldBody("Content-Type", headers["Content-Type"].ToString()); this.TopLevelMediaType = (MimeTopLevelMediaType)System.Enum.Parse(TopLevelMediaType.GetType(), this.ContentType["Content-Type"].Split('/')[0], true); this.Subtype = this.ContentType["Content-Type"].Split('/')[1]; this.Enc = MimeTools.parseCharSet(this.ContentType["charset"]); } catch (System.Exception) { this.Enc = default_encoding; this.ContentType = MimeTools.parseHeaderFieldBody("Content-Type", System.String.Concat("text/plain; charset=", this.Enc.BodyName)); this.TopLevelMediaType = MimeTopLevelMediaType.text; this.Subtype = "plain"; } if (this.Enc == null) { this.Enc = default_encoding; } // TODO: rework this try { this.ContentdisPosition = MimeTools.parseHeaderFieldBody("Content-Disposition", headers["Content-Disposition"].ToString()); } catch (System.Exception) { this.ContentdisPosition = new System.Collections.Specialized.StringDictionary(); } try { this.ContentLocation = MimeTools.parseHeaderFieldBody("Content-Location", headers["Content-Location"].ToString()); } catch (System.Exception) { this.ContentLocation = new System.Collections.Specialized.StringDictionary(); } }
/// <summary> /// Decode rfc 2047 definition of quoted-printable /// </summary> /// <param name="charset">charset to use when decoding</param> /// <param name="orig"><c>string</c> to decode</param> /// <returns>the decoded <see cref="System.String" /></returns> public static System.String QuotedPrintable2Unicode(System.String charset, System.String orig) { System.Text.Encoding enc = MimeTools.parseCharSet(charset); if (enc == null || orig == null) { return(orig); } MimeTools.QuotedPrintable2Unicode(enc, ref orig); return(orig); }