Repository: beeware/briefcase

Issue:
Windows packaging fails on non-Latin filenames
Reported by user `@betterer` on Discord.

If a project contains a non-Latin file name, the WiX compilation process fails, even though the app itself can run. This includes if the app doesn't use the file at all. The mere existence of a non-Latin filename by itself is enough to break Windows MSI packaging.

**To Reproduce**
Steps to reproduce the behavior:
1. Create a new Hello World app
2. Duplicate `app.py` as `app_副本.py`
3. Run `briefcase package`
4. See error

```
...
[dialogs] Building MSI...

Compiling application manifest...

Compiling application installer...
dialogs.wxs
dialogs-manifest.wxs

Linking application installer...
Z:\projects\beeware\toga\examples\dialogs\windows\msi\Dialog Demo\dialogs-manifest.wxs(19) : error LGHT0311 : A string was provided with characters that are not available in the specified database code page '1252'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the following attributes: Product/@Codepage, Module/@Codepage, Patch/@Codepage, PatchCreation/@Codepage, or WixLocalization/@Codepage.

Unable to link app dialogs.

```
**Expected behavior**

i18n filenames should not break the packaging process.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment:**
 - Operating System: Windows
 - Python version: all
 - Software versions:
   - Briefcase: 0.3.7

**Additional context**

The error message contains a candidate fix - adding a codepage declaration to the Product declaration. However, we need to be sure that this doesn't cause the filename to be corrupted by the packaging process.


Comments:

Patch:
diff --git a/changes/749.bugfix.rst b/changes/749.bugfix.rst
new file mode 100644
index 00000000..8f2f21f6
--- /dev/null
+++ b/changes/749.bugfix.rst
@@ -0,0 +1,1 @@
+Windows MSI projects are now able to support files with non-ASCII filenames.
diff --git a/src/briefcase/platforms/windows/msi.py b/src/briefcase/platforms/windows/msi.py
index 42a7d2d9..0023f89d 100644
--- a/src/briefcase/platforms/windows/msi.py
+++ b/src/briefcase/platforms/windows/msi.py
@@ -208,6 +208,8 @@ class WindowsMSIPackageCommand(WindowsMSIMixin, PackageCommand):
                         "WixUtilExtension",
                         "-ext",
                         "WixUIExtension",
+                        "-loc",
+                        "unicode.wxl",
                         "-o",
                         self.distribution_path(app, packaging_format="msi"),
                         f"{app.app_name}.wixobj",


Test patch:
diff --git a/tests/platforms/windows/msi/test_package.py b/tests/platforms/windows/msi/test_package.py
index 882d27a1..ed4725e7 100644
--- a/tests/platforms/windows/msi/test_package.py
+++ b/tests/platforms/windows/msi/test_package.py
@@ -70,6 +70,8 @@ def test_package_msi(package_command, first_app_config, tmp_path):
                     "WixUtilExtension",
                     "-ext",
                     "WixUIExtension",
+                    "-loc",
+                    "unicode.wxl",
                     "-o",
                     tmp_path / "windows" / "First App-0.0.1.msi",
                     "first-app.wixobj",