I was modified the *.tt files under "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\CodeTemplates\AddView" folder. Everytime I Add a new View, the output file encoding are just UTF-8 without BOM. Even I specify
encoding as "ASCII" or "BIG5", the output file encoding still UTF-8 without BOM.
The problem I met is that when the strong-typed Model passed to the View, and the Model Type name contains non-ASCII characters. The view will not able to rendered due to C# compilation errror. That's because the C# compiler doesn't recognize the file
encoding with "UTF-8 without BOM". The C# compiler just treat "UTF-8 without BOM" file as "ASCII" or "Default" encoding, so that the compilation failed.
Does anyone who met this problem before? This problem has plagued me for a while and I think this problem will plague Asian developers too.
This problem still exists. Due to Razor parser unable to parse a file with UTF-8 without BOM encoding with any Unicode characters in the CSHTML file. So any file generated by T4 with some Unicode characters will cause compilation error problem. Which
means there are many T4-like solution such as MvcScaffolding are not able to deal with Unicode TypeName in any project.
Doggy8088
Member
41 Points
110 Posts
How to force T4 generated files saves as UTF-8 with BOM when using Add View
Nov 20, 2009 01:51 PM|LINK
Hi,
I was modified the *.tt files under "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\CodeTemplates\AddView" folder. Everytime I Add a new View, the output file encoding are just UTF-8 without BOM. Even I specify encoding as "ASCII" or "BIG5", the output file encoding still UTF-8 without BOM.
Is that a MVC T4 Host's problem?
ASP.NET MVC t4 MVC bug
http://blog.miniasp.com/
Doggy8088
Member
41 Points
110 Posts
Re: How to force T4 generated files saves as UTF-8 with BOM when using Add View
Nov 21, 2009 11:46 AM|LINK
Sorry! I forgot to mention the problem I got.
The problem I met is that when the strong-typed Model passed to the View, and the Model Type name contains non-ASCII characters. The view will not able to rendered due to C# compilation errror. That's because the C# compiler doesn't recognize the file encoding with "UTF-8 without BOM". The C# compiler just treat "UTF-8 without BOM" file as "ASCII" or "Default" encoding, so that the compilation failed.
Does anyone who met this problem before? This problem has plagued me for a while and I think this problem will plague Asian developers too.
ASP.NET MVC
http://blog.miniasp.com/
Eilon
Contributor
5753 Points
976 Posts
Microsoft
Re: How to force T4 generated files saves as UTF-8 with BOM when using Add View
Nov 24, 2009 06:12 PM|LINK
Hi there,
I've reported this issue to the folks who work on the MVC tools for Visual Studio so that they can investigate.
Thanks,
Eilon
Eilon
Contributor
5753 Points
976 Posts
Microsoft
Re: How to force T4 generated files saves as UTF-8 with BOM when using Add View
Nov 24, 2009 06:23 PM|LINK
Hi there,
I've reported this issue to the folks who work on the MVC tools for Visual Studio so that they can investigate.
Thanks,
Eilon
Doggy8088
Member
41 Points
110 Posts
Re: How to force T4 generated files saves as UTF-8 with BOM when using Add View
Nov 25, 2009 03:54 AM|LINK
Thanks!
http://blog.miniasp.com/
Doggy8088
Member
41 Points
110 Posts
Re: How to force T4 generated files saves as UTF-8 with BOM when using Add View
Apr 12, 2012 05:40 PM|LINK
Hi Eilon,
This problem still exists. Due to Razor parser unable to parse a file with UTF-8 without BOM encoding with any Unicode characters in the CSHTML file. So any file generated by T4 with some Unicode characters will cause compilation error problem. Which means there are many T4-like solution such as MvcScaffolding are not able to deal with Unicode TypeName in any project.
Hope can get any response on this issue. Thanks!
http://blog.miniasp.com/
Doggy8088
Member
41 Points
110 Posts
Re: How to force T4 generated files saves as UTF-8 with BOM when using Add View
Nov 12, 2012 05:40 PM|LINK
This problem was just resolved by unknown reason.
http://blog.miniasp.com/