[英]Is it possible to use latin character in comments of t4 template?
I'm trying to create a portuguese comments in a t4 template of the Add Controller in my project. 我正在尝试在我的项目中添加控制器的t4模板中创建葡萄牙语注释。
The comments in t4 template: t4模板中的注释:
/// <summary>
/// Controller que trata as requisições de pesquisa, inclusão, alteração e exclusão de <#= mvcHost.ControllerName.Replace("Controller", "") #>.
/// </summary>
The problem is when i add a controller, the comments appear like this: 问题是当我添加一个控制器时,注释显示如下:
/// <summary>
/// Controller que trata as requisi��es de pesquisa, inclus�o, altera��o e exclus�o de Teste.
/// </summary>
Obs: The square is the black "? diamond" symbol. Obs:方形 是黑色的“钻石”符号。
So, how can i use latin characteres in a t4 template? 那么,我如何在t4模板中使用拉丁字符呢?
My Template: 我的模板:
<#@ template language="C#" HostSpecific="True" #>
<#@ output extension=".cs" encoding="UTF-8" #>
<#
MvcTextTemplateHost mvcHost = (MvcTextTemplateHost)(Host);
#>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace <#= mvcHost.Namespace #>
{
/// <summary>
/// Controller que trata as requisições de pesquisa, inclusão, alteração e exclusão de <#= mvcHost.ControllerName.Replace("Controller", "") #>.
/// </summary>
public class <#= mvcHost.ControllerName #> : Controller
{
// The class code
}
}
Try to specify the encoding explicitly for the output of your templates: 尝试为模板的输出明确指定编码:
<#@ output extension=".cs" encoding="UTF-8" #>
Edit : Your code works correctly on mine (after removing the mvcHost
parts). 编辑 :您的代码在我的代码上正常工作(删除
mvcHost
部分后)。
Try resaving both your template and its output file as UTF-8 by performing this procedure for each: 尝试通过对每个模板执行此过程将模板及其输出文件重新保存为UTF-8:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.