NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

StreamReader.SwitchEncoding (Encoding)

Switches the current stream's encoding to the new one, reading from the current position onward.

[Visual Basic]
Overloads Overridable Public Sub SwitchEncoding( _
   ByVal enc As Encoding _
)
[C#]
public virtual void SwitchEncoding(
   Encoding enc
);
[C++]
public: virtual void SwitchEncoding(
   Encoding* enc
);
[JScript]
public function SwitchEncoding(
   enc : Encoding
);

Parameters

enc
The new encoding to use.

Exceptions

Exception Type Condition
ArgumentNullException enc is a null reference (in Visual Basic Nothing).
InvalidOperationException SwitchEncoding is called after reading the second time from the underlying stream.

Remarks

SwitchEncoding supports the reading of a few lines of header information in one encoding, and then reading the rest of the document in a different encoding.

Use SwitchEncoding(Encoding, int) to re-encode from a specified character position in the stream onward, and to read restrictions on the use of SwitchEncoding.

See Also

StreamReader Class | StreamReader Members | System.IO Namespace | StreamReader.SwitchEncoding Overload List