Anders Forsgren
Anders Forsgren

Reputation: 11101

WiX Installer heat.exe and non-ascii filenames

I added a file in my WiX script with the character " î " in the path name. Light.exe will complain:

A string was provided with characters that are not available in the specified database code page '1252'

The character in question is 0xEE in Windows-1252 encoding, that is, 0x00EE Unicode or 0xC3AE in UTF-8. These files are in a wxs file generated by heat.exe, and this xml is encoded as UTF-8.

I assume the error message comes from the fact that it tries to input the character in UTF encoding while the database is 1252? Since UTF isn't really supported by Windows Installer (as described in the WiX documentation), should I be using input xml encoded in 1252 or iso-8859? If so, can I tell heat.exe to use another encoding for its output?

My question is similar to this one: Leveraging heat.exe and harvest already localized file names and including them to msi using wix but the difference is that in that case the characters are "true" non-ansi charcaters, in my case the character can be encoded correctly in 1252, but it seems the conversion from utf-8 input files does not work.

Upvotes: 4

Views: 1419

Answers (1)

Rob Mensching
Rob Mensching

Reputation: 35901

The WiX toolset verifies codepages like so (roughly):

encoding = Encoding.GetEncoding(codepage, new EncoderExceptionFallback(),
                                          new DecoderExceptionFallback());
writer = new StreamWriter(idtPath, false, encoding);
try
{
   // GetBytes will throw an exception if any character doesn't
   // match our current encoding
   rowBytes = writer.Encoding.GetBytes(rowString);
}
catch (EncoderFallbackException)
{
    rowBytes = convertEncoding.GetBytes(rowString);

    messageHandler.OnMessage(WixErrors.InvalidStringForCodepage(
                                row.SourceLineNumbers,
                                writer.Encoding.WindowsCodePage));
}

It is possible that NETFX is not translating that "i" correctly. Explicitly setting the codepage on your XML may help. To do that from heat, you can try to use an XSLT (I've never tried changing the XML doc codepage via XSL but seems possible) or post-edit the document.

Upvotes: 1

Related Questions