Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

tangible
#1 Posted : Tuesday, May 12, 2009 12:02:33 PM(UTC)
Guest
Rank: Guest

Groups: Guest
Joined: 3/17/2009(UTC)
Posts: 1,084

Hello,

If you have trouble with special characters you might want to insert the following code in your template

<#@ template hostSpecific="true" #>
<#
this.Host.SetOutputEncoding(System.Text.Encoding.UTF8,false);
#>

This way you can set the output encoding. The T4 Editor is always using UTF8. Visual Studio recognizes UTF-8 so
there are never issues with your template - however some other T4 Tools and Addons also provide a custom host
which might default to another encoding. By calling this method you determine which encoding should be used.

This is a typical string you will encounter issues with when embedding in a T4 file without setting the encoding
(if you have no trickery tool installed).

private const string testData = "§";

Note if this string renders correctly in your output and you have not set the encoding then the custom host you are using
(maybe defined by another tool is changing the default encoding - without asking you).

Edited by user Monday, June 8, 2009 1:19:24 PM(UTC)  | Reason: Not specified

Guest
#2 Posted : Tuesday, May 12, 2009 1:02:32 PM(UTC)
Guest
Rank: Guest

Groups: Guest
Joined: 3/17/2009(UTC)
Posts: 1,084

Hello,

Thanks for providing this info.

I tried the proposed solution. It worked perfectly.

Thanks for all.
tangible
#3 Posted : Saturday, May 16, 2009 10:00:57 PM(UTC)
Guest
Rank: Guest

Groups: Guest
Joined: 3/17/2009(UTC)
Posts: 1,084

Just for completeness you can also specify the encoding in the <#@output#> directive like this

<#@ output encoding="UTF8" #>
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF | YAF © 2003-2020, Yet Another Forum.NET
This page was generated in 0.061 seconds.

Authorization on the site

For an authorized user opens up new possibilities

Login

Password