There may be a time when you need to use Extended ASCII Codes in your CodeSmith Generator Templates. If you have already tried using them into your template you have more than likely ran into the following problem. When a user first creates a template an Encoding attribute is not added by default to the CodeTemplate directive. So when a user starts adding characters in the Extended ASCII range, they will run into the following problem without first setting the encoding attribute. If you don’t add the Encoding Attribute to your template before saving, closing and reopening your template. You will be greeted by something like this.
The solution to this problem is to add an Encoding attribute to the CodeTemplate directive before saving.
<%@ CodeTemplate="" language="C#" TargetLanguage="C#">
Make sure you add the
Encoding attribute as shown below.
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Encoding="UTF-8" %></%@>
Share this post