Freigeben über


XmlWriterSettings.Encoding Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the text encoding to use.

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

Syntax

'Declaration
Public Property Encoding As Encoding
public Encoding Encoding { get; set; }

Property Value

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

Remarks

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.

Version Information

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

Platforms

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