Make the Windows launcher work with Unicode paths

On Windows, the `C:\Users\<username>` path will often contain the user's real human name. When this path contains characters outside the current "ANSI code page" (an old DOS concept that predates Unicode), lots of different things break, and NetBeans will fail to work. See https://github.com/apache/netbeans/issues/4314.

The underlying problem is that both OpenJDK and the NetBeans launcher, like most old Windows software, tend to use the "ANSI" versions of Win32 APIs rather than the "Wide Char" versions (e.g. GetCurrentDirectoryA instead of GetCurrentDirectoryW). About 3 years ago, Microsoft started recommending an easy solution: Rather than replacing "char *" with "wchar_t *" everywhere, we can now set UTF-8 as the default "code page" for all ANSI Win32 API calls, at the EXE file process level. We do this here for the NetBeans Windows launcher. See https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page

Since the NetBeans Windows launcher uses JNI to start Java in-process, the JVM inherits the same default code page setting, without the user having to change regional settings in the Control Panel. Everything then works consistently; passing of system properties into the JVM, loading of libraries from Unicode paths from the system classloader or JNA, and so on. This assumes that the JVM takes its Win32 code page setting from the "user" locale (the GetACP() Win32 function) rather than the "system" locale. This been explicitly the case since https://bugs.openjdk.org/browse/JDK-8272352, in Java 19 and recent backports to Java 11.0.17 and Java 17.0.5.

We also set the UTF-8 code page for the windows console, so that Unicode characters display correctly there.

On the aforementioned recent Java versions, NetBeans should now run fine when there are Unicode characters in the NetBeans installation path, the JDK path, the user/cache directory paths, or in the java.io.tmpdir path (the latter sometimes being a problem for JNA, which is used by FlatLAF). This was tested on Java 17.0.5 with Cyrillic and Norwegian characters in the OS home directory path and all of the paths above, with different combinations of Cyrillic vs. US English code pages set at the user vs. system level ("Formats/Format" vs. "Administrative/Change System Locale" in the "Region" control panel dialog). Both the NetBeans IDE launcher and a NetBeans Platform application launcher were tested.
6 files changed