EncodingHelper.GetEncoding Method

Determines the encoding of the specified file from its byte order mark.

Namespace:  Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating (in Microsoft.VisualStudio.TextTemplating.dll)

Syntax

'宣言
Public Shared Function GetEncoding ( _
    filePath As String _
) As Encoding
'使用
Dim filePath As String
Dim returnValue As Encoding

returnValue = EncodingHelper.GetEncoding(filePath)
public static Encoding GetEncoding(
    string filePath
)
public:
static Encoding^ GetEncoding(
    String^ filePath
)
public static function GetEncoding(
    filePath : String
) : Encoding

Parameters

  • filePath
    Type: System.String

    The file to determine the encoding of.

Return Value

Type: System.Text.Encoding

An Encoding that contains the encoding information. The default is Default, the current ANSI code page of the system.

Exceptions

Exception Condition
ArgumentNullException

filePath is a null reference (Nothing in Visual Basic).

Remarks

When a user creates a text template, they can specify the encoding that they want the text template host to use to create the generated text. If the user does not specify the encoding, the host calls this method to determine the encoding of the text template. The host can then use the same encoding to create the generated text.

Permissions

See Also

Concepts

Generating Artifacts Using Text Templates

How to: Specify File Output Types in Text Templates

Directive Syntax (Domain-Specific Languages)

Reference

EncodingHelper Class

EncodingHelper Members

Microsoft.VisualStudio.TextTemplating Namespace

Other Resources

Byte Order Mark