Index: trunk/native/linux/latest/usr/bin/josm-latest
===================================================================
--- trunk/native/linux/latest/usr/bin/josm-latest	(revision 19519)
+++ trunk/native/linux/latest/usr/bin/josm-latest	(revision 19637)
@@ -58,4 +58,17 @@
     # shellcheck source=/etc/default/josm-latest
     . "/etc/default/${JOSM_VERSION}"
+fi
+
+# Java decodes file names with the character set of the locale, and -Dsun.jnu.encoding
+# cannot override it. If the locale is C/POSIX, or cannot be set at all - typically a
+# UTF-8 LANG whose locale is not installed, as in a Flatpak sandbox - file names are
+# decoded as ASCII and opening a folder that holds a non-ASCII name fails with
+# InvalidPathException. Fall back to C.UTF-8 then, which is built into glibc 2.35 and
+# later. This does not change the language of JOSM: when the locale cannot be set, Java
+# already falls back to English. LC_ALL is needed, as setlocale() fails as a whole if
+# any category names a locale that is not installed.
+if { [ -n "$(locale 2>&1 >/dev/null)" ] || [ "$(locale charmap 2>/dev/null)" = "ANSI_X3.4-1968" ]; } \
+        && [ -z "$(LC_ALL=C.UTF-8 locale 2>&1 >/dev/null)" ]; then
+    export LC_ALL=C.UTF-8
 fi
 
Index: trunk/native/linux/tested/usr/bin/josm
===================================================================
--- trunk/native/linux/tested/usr/bin/josm	(revision 19519)
+++ trunk/native/linux/tested/usr/bin/josm	(revision 19637)
@@ -58,4 +58,17 @@
     # shellcheck source=/etc/default/josm
     . "/etc/default/${JOSM_VERSION}"
+fi
+
+# Java decodes file names with the character set of the locale, and -Dsun.jnu.encoding
+# cannot override it. If the locale is C/POSIX, or cannot be set at all - typically a
+# UTF-8 LANG whose locale is not installed, as in a Flatpak sandbox - file names are
+# decoded as ASCII and opening a folder that holds a non-ASCII name fails with
+# InvalidPathException. Fall back to C.UTF-8 then, which is built into glibc 2.35 and
+# later. This does not change the language of JOSM: when the locale cannot be set, Java
+# already falls back to English. LC_ALL is needed, as setlocale() fails as a whole if
+# any category names a locale that is not installed.
+if { [ -n "$(locale 2>&1 >/dev/null)" ] || [ "$(locale charmap 2>/dev/null)" = "ANSI_X3.4-1968" ]; } \
+        && [ -z "$(LC_ALL=C.UTF-8 locale 2>&1 >/dev/null)" ]; then
+    export LC_ALL=C.UTF-8
 fi
 
