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 );
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. |
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.
StreamReader Class | StreamReader Members | System.IO Namespace | StreamReader.SwitchEncoding Overload List