Encoding Property

XmlWriterSettings.Encoding Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft