博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

CodeSmith不能保存中文的解决办法

Posted on 2007-03-05 13:44  江南白衣  阅读(688)  评论(0编辑  收藏  举报
昨天在用ActiveRecord Template的时候发现CodeSmith不能正常输出中文,解决方法如下:
设置CodeSmith   tools->option->Enable  unicode  support  
在模板中加入“ResponseEncoding="UTF-8" ”:
<%@ CodeTemplate Language="C#" ResponseEncoding="UTF-8" %>

CodeSmith的文档是这么说的:

Q. What if my template contains non-ASCII characters?
A. You can use the ResponseEncoding attribute of the CodeTemplate directive to set the encoding for the template.

ResponseEncoding
    The ResponseEncoding attribute is used to set the encoding for the template content and it's outputs.  The ResponseEncoding attribute supports values from the System.Text.Encoding.GetEncoding method.  By default, the encoding is set to ASCII.