Encoding Property

XmlWriterSettings.Encoding Property

Gets or sets the text encoding to use.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public Encoding Encoding { get; set; }

Property Value

Type: System.Text.Encoding
The text encoding to use. The default is Encoding.UTF8.

This property only applies to XmlWriter instances that output text content to a stream; otherwise, this setting is ignored. The XmlWriter encodes a buffer of characters at a time, rather than character by character. An exception is thrown when the Flush method is called if any encoding errors are encountered.

This property is overridden by the encoding of the underlying writer. For example, if this property is set to Unicode for a particular XmlWriter, but the underlying writer is a StreamWriter with encoding set to UTF8, the output will be UTF8 encoded.

Security noteSecurity Note:

Do not accept an Encoding object from an untrusted source.

For more information and code examples, see XML Data.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2016 Microsoft