Table of Contents

FallbackEncodingOptions Class

Definition

Namespace
Cuemon.Text
Assemblies
Cuemon.Kernel.dll
Source
src/Cuemon.Kernel/Text/FallbackEncodingOptions.cs

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

Name Description
FallbackEncodingOptions()

Initializes a new instance of the FallbackEncodingOptions class.

Properties

Name Description
DecoderFallback

Gets or sets 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.

TargetEncoding

Gets or sets the target encoding for the operation.

See Also