title: T4 Template Save as Unicode
body: <p>I use Template - Generator architect as Oleg Sych said to generate some code by T4, but there is some problems in using Unicode, I have some Persian characters after generate all of the Persian characters displayed as question mark.</p>
  
  <p>This is my files: Template:</p>
  
  <pre><code>&lt;#@ assembly name="Microsoft.SqlServer.ConnectionInfo" #&gt;
  &lt;#@ assembly name="Microsoft.SqlServer.Smo" #&gt;
  &lt;#@ assembly name="Microsoft.SqlServer.Management.Sdk.Sfc" #&gt;
  &lt;#@ import namespace="Microsoft.SqlServer.Management.Smo" #&gt;
  &lt;#@ import namespace="System.Collections.Generic" #&gt;
  &lt;#+
  public class DALTable : Template
  {
  
      public override string TransformText()
      {
  
          //My Template
  
      }
  </code></pre>
  
  <p>Generator:</p>
  
  <pre><code>&lt;#@ assembly name="Microsoft.SqlServer.ConnectionInfo" #&gt;
  &lt;#@ assembly name="Microsoft.SqlServer.Smo" #&gt;
  &lt;#@ assembly name="Microsoft.SqlServer.Management.Sdk.Sfc" #&gt;
  &lt;#@ include file="DALTable.tt" #&gt;
  &lt;#+
  public class TableDALGenerator : Generator
  {
      public DALTable DALTableTemplate = new DALTable();
  
      protected override void RunCore()
  {
          this.DALTableTemplate.Table = table;
          this.DALTableTemplate.RenderToFile("DAL.cs");
      }
   }
  </code></pre>
  
  <p>And Script:</p>
  
  <pre><code>&lt;#@ template language="C#v4" hostspecific="True" debug="True" #&gt;
  &lt;#@ assembly name="System.Core" #&gt;
  &lt;#@ output extension=".cs" encoding="UTF8" #&gt;
  &lt;#@ include file="T4Toolbox.tt" #&gt;
  &lt;#@ include file="TableDALGenerator.tt" #&gt;
  &lt;#
      TableDALGenerator TableDALGen = new TableDALGenerator();
      //Pass Parameters
      TableORMGen.Run();
  #&gt;
  </code></pre>
  
  <p>As Oleg Sych said I set Unicode in output as you see in this line: <code>&lt;#@ output extension=".cs" encoding="UTF8" #&gt;</code> also I save as all of this 3 files with Unicode <code>utf8</code>
  but the problem still remain, where is the problem? what another thing remain that I must do that? </p>
  
  <p><strong>Update</strong></p>
  
  <p>I found that none of my new generated files (DAL.cs) not saved as <code>UTF8</code> all of them saved by <code>ANSI</code> encoding. what need to do to save my files by <code>UTF8</code> encoding?</p>