Table of Contents

Class FallbackEncodingOptions

Namespace
Cuemon.Text
Assembly
Cuemon.Kernel.dll

Configuration options related to Encoding.

public class FallbackEncodingOptions : EncodingOptions, IEncodingOptions, IParameterObject
Inheritance
FallbackEncodingOptions
Implements
Inherited Members

Examples

The following example demonstrates how to configure FallbackEncodingOptions to use exception fallbacks when encoding or decoding characters that are not supported by the target encoding.

using System.Text;
using Cuemon.Text;

namespace MyApp.Examples;

public class FallbackEncodingOptionsExample
{
    public void Demonstrate()
    {
        var options = new FallbackEncodingOptions
        {
            TargetEncoding = Encoding.ASCII,
            EncoderFallback = EncoderFallback.ExceptionFallback,
            DecoderFallback = DecoderFallback.ExceptionFallback,
            Encoding = Encoding.UTF8,
            Preamble = PreambleSequence.Remove
        };

        // The options are ready to be used with encoding operations
        // that respect FallbackEncodingOptions. When an unsupported
        // character is encountered, an EncoderFallbackException will be thrown.

}
}

Constructors

FallbackEncodingOptions()

Initializes a new instance of the FallbackEncodingOptions class.

public FallbackEncodingOptions()

Remarks

The following table shows the initial property values for an instance of FallbackEncodingOptions.

PropertyInitial Value
EncoderFallbackEncoderFallback.ExceptionFallback
DecoderFallbackDecoderFallback.ExceptionFallback

Properties

DecoderFallback

Gets or sets the object that provides an error-handling procedure when a byte sequence cannot be decoded.

public DecoderFallback DecoderFallback { get; set; }

Property Value

DecoderFallback

The object that provides an error-handling procedure when a byte sequence cannot be decoded.

EncoderFallback

Gets or sets the object that provides an error-handling procedure when a character cannot be encoded.

public EncoderFallback EncoderFallback { get; set; }

Property Value

EncoderFallback

The object that provides an error-handling procedure when a character cannot be encoded.

TargetEncoding

Gets or sets the target encoding for the operation.

public Encoding TargetEncoding { get; set; }

Property Value

Encoding

The target encoding for the operation.

Exceptions

ArgumentNullException

value cannot be null.

See Also