Share via


EncodingHelper.GetEncoding Method

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

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

Syntax

'Declaration
Public Shared Function GetEncoding ( _
    filePath As String _
) As Encoding
public static Encoding GetEncoding(
    string filePath
)
public:
static Encoding^ GetEncoding(
    String^ filePath
)
static member GetEncoding : 
        filePath:string -> Encoding
public static function GetEncoding(
    filePath : String
) : Encoding

Parameters

  • filePath
    Type: String

    The file to determine the encoding of.

Return Value

Type: 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 nulla 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.

.NET Framework Security

See Also

Reference

EncodingHelper Class

Microsoft.VisualStudio.TextTemplating Namespace

Other Resources

Byte Order Mark

Code Generation and T4 Text Templates

How to: Specify File Output Types in Text Templates

T4 Text Template Directives