This documentation is archived and is not being maintained.

ITextTemplatingEngineHost.SetOutputEncoding Method

Tells the host the encoding that is expected for the generated text output.

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

Sub SetOutputEncoding ( _
	encoding As Encoding, _
	fromOutputDirective As Boolean _


Type: Encoding

The encoding for the generated text output.

Type: Boolean

true to indicate that the user specified the encoding in the encoding parameter of the output directive.

The engine calls this method if the user has specified the optional encoding parameter of the template directive in a text template. For more information, see T4 Text Template Directives.

The following code example shows a possible implementation for a custom host. This code example is part of a larger example. For the complete example, see Walkthrough: Creating a Custom Text Template Host.

Private fileEncodingValue As Encoding = Encoding.UTF8
Public ReadOnly Property fileEncoding() As Encoding
        Return fileEncodingValue
    End Get
End Property

Public Sub SetOutputEncoding(ByVal encoding As System.Text.Encoding, ByVal fromOutputDirective As Boolean) Implements ITextTemplatingEngineHost.SetOutputEncoding

    fileEncodingValue = encoding
End Sub