| File: System\Text\Encodings\Web\HtmlEncoder.cs | Web Access |
| Project: src\runtime\src\libraries\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj (System.Text.Encodings.Web) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Unicode; namespace System.Text.Encodings.Web { /// <summary> /// Represents a type used to do HTML encoding. /// </summary> public abstract class HtmlEncoder : TextEncoder { /// <summary> /// Returns a default built-in instance of <see cref="HtmlEncoder"/>. /// </summary> public static HtmlEncoder Default => DefaultHtmlEncoder.BasicLatinSingleton; /// <summary> /// Creates a new instance of HtmlEncoder with provided settings. /// </summary> /// <param name="settings">Settings used to control how the created <see cref="HtmlEncoder"/> encodes, primarily which characters to encode.</param> /// <returns>A new instance of the <see cref="HtmlEncoder"/>.</returns> public static HtmlEncoder Create(TextEncoderSettings settings) { return new DefaultHtmlEncoder(settings); } /// <summary> /// Creates a new instance of HtmlEncoder specifying character to be encoded. /// </summary> /// <param name="allowedRanges">Set of characters that the encoder is allowed to not encode.</param> /// <returns>A new instance of the <see cref="HtmlEncoder"/></returns> /// <remarks>Some characters in <paramref name="allowedRanges"/> might still get encoded, i.e. this parameter is just telling the encoder what ranges it is allowed to not encode, not what characters it must not encode.</remarks> public static HtmlEncoder Create(params UnicodeRange[] allowedRanges) { return new DefaultHtmlEncoder(new TextEncoderSettings(allowedRanges)); } } }