public static HtmlEncode ( char data, int startIndex, int count ) : string | ||
data | char | The character data to encode. |
startIndex | int | The starting index of the character data. |
count | int | The number of characters in the data. |
리턴 | string |
/// <summary> /// Write the HTML character data to a <see cref="System.IO.TextWriter"/>. /// </summary> /// <remarks> /// Writes the HTML character data to a <see cref="System.IO.TextWriter"/>, /// encoding it if it isn't already encoded. /// </remarks> /// <param name="output">The output.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="output"/> is <c>null</c>. /// </exception> public override void WriteTo(TextWriter output) { if (output == null) { throw new ArgumentNullException(nameof(output)); } if (!EncodeEntities) { output.Write(Data); return; } HtmlUtils.HtmlEncode(output, Data); }
/// <summary> /// Write text to the output stream, escaping special characters. /// </summary> /// <remarks> /// Writes text to the output stream, escaping special characters. /// </remarks> /// <param name="buffer">The text buffer.</param> /// <param name="index">The index of the first character to write.</param> /// <param name="count">The number of characters to write.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="buffer"/> is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <para><paramref name="index"/> is less than zero or greater than the length of /// <paramref name="buffer"/>.</para> /// <para>-or-</para> /// <para><paramref name="index"/> and <paramref name="count"/> do not specify /// a valid range in the <paramref name="buffer"/>.</para> /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteText(char[] buffer, int index, int count) { ValidateArguments(buffer, index, count); CheckDisposed(); if (WriterState != HtmlWriterState.Default) { WriterState = HtmlWriterState.Default; html.Write(empty ? "/>" : ">"); empty = false; } if (count > 0) { HtmlUtils.HtmlEncode(html, buffer, index, count); } }
/// <summary> /// Write text to the output stream, escaping special characters. /// </summary> /// <remarks> /// Writes text to the output stream, escaping special characters. /// </remarks> /// <param name="value">The text.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="value"/> is <c>null</c>. /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteText(string value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } CheckDisposed(); if (WriterState != HtmlWriterState.Default) { WriterState = HtmlWriterState.Default; html.Write(empty ? "/>" : ">"); empty = false; } if (value.Length > 0) { HtmlUtils.HtmlEncode(html, value.ToCharArray(), 0, value.Length); } }