StreamWriter.Encoding Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the Encoding in which the output is written.
public:
virtual property System::Text::Encoding ^ Encoding { System::Text::Encoding ^ get(); };
public override System.Text.Encoding Encoding { get; }
member this.Encoding : System.Text.Encoding
Public Overrides ReadOnly Property Encoding As Encoding
Property Value
The Encoding specified in the constructor for the current instance, or UTF8Encoding if an encoding was not specified.
Examples
The following example retrieves the encoding of the specified StreamWriter instance.
// Write out the current text encoding
sw->WriteLine( "Encoding: {0}",
sw->Encoding->ToString() );
// Write out the current text encoding
sw.WriteLine("Encoding: {0}",
sw.Encoding.ToString());
' Write out the current text encoding.
Sw.WriteLine("Encoding: {0}", _
Sw.Encoding.ToString())
Remarks
This property is necessary for some XML scenarios where a header must be written containing the encoding used by the StreamWriter. This allows the XML code to consume an arbitrary StreamWriter and generate the correct XML header.
For a list of common I/O tasks, see Common I/O Tasks.
Applies to
See also
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om