Variables with values containing unicode characters are not transformed correctly

We have projects that have variables with values in German (e.g letters with umlauts). We found that the variable substitution step is correctly substituting the values in the config transform files, but the final transformed web.config has boxes instead of the umlauts. For example, we have a variable called “LocalizedTerms” with a value of “Die allgemeinen Geschäftsbedingungen”. Our transform file has the following :
<add xdt:Locator="Match(key)" xdt:Transform="Replace" key="TermsAndConditions" value="#{LocalizedTerms}" />

Our web.config has the following app setting:
<add key="TermsAndConditions" value="Foobar" />

Now when the deployment runs, we see that the substitution feature is run first, the new on the server correctly shows:
<add xdt:Locator="Match(key)" xdt:Transform="Replace" key="TermsAndConditions" value="Die allgemeinen Geschäftsbedingungen" />

But the final transformed web.config looks like this:
<add key="TermsAndConditionsUrl" value="Die allgemeinen Gesch�ftsbedingungen" />

We made sure that the web.config and the are UTF-8. Is the code doing the transformations not respected the desired encoding?

Update: I changed the substitution step to explicitly set the encoding to be “UTF-8” and the umlauts correctly appear now in the web.config. So for some reason, the autodetect stuff wasn’t working.


Thanks for getting in touch. Unfortunately I could not reproduce the bug. Note that the automatic encoding detection determines the encoding by looking at the BOM (Byte Order Mark) in the source transform file, not the attribute in the XML header. Could you please check that the file is encoded correctly? Notepad++ is a good tool to use for this, as it shows you the encoding in the bottom right hand corner when viewing the file and allows you to change it.

If the encoding on is right, or correcting does not fix the problem, could you check the output encoding of the final web.config file.

This is the project I used to test this case, and I configured Octopus replace configuration variable, run configuration transforms and substitute variables in *.config files with Detect from template output file encoding.

If you continue to have problems, please let me know,

Robert W

That’s my problem: the web.config has a BOM, but the
transform file does not have a BOM.