/// <summary> /// Create a new CQ object from an HTML string. /// </summary> /// /// <param name="html"> /// The HTML source. /// </param> /// <param name="parsingMode"> /// The HTML parsing mode. /// </param> /// <param name="parsingOptions"> /// (optional) options for controlling the parsing. /// </param> /// <param name="docType"> /// (optional) type of the document. /// </param> public CQ(string html, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default) { var encoding = new UTF8Encoding(false); using (var stream = Support2.GetEncodedStream(html ?? "", encoding)) { CreateNew(this, stream, encoding, parsingMode, parsingOptions, docType); } }
/// <summary> /// Convert a string to a stream. /// </summary> /// /// <param name="input"> /// The input to act on. /// </param> /// <param name="encoding"> /// (optional) the encoding of the stream. Defaults to UTF8 /// </param> /// /// <returns> /// input as a Stream. /// </returns> public static Stream ToStream(this string input, Encoding encoding = null) { encoding = encoding ?? new UTF8Encoding(false); return(Support2.GetEncodedStream(input ?? "", encoding)); }