mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-24 14:34:15 +08:00
修复中文路径下启动 <= 1.12.2 的版本没有声音的问题 (#1754)
* Use native encoding by default * Fix the problem that LWJGL fails to load OpenAL under Java 18
This commit is contained in:
parent
2649e79d47
commit
43986676d8
@ -108,24 +108,26 @@ public class DefaultLauncher extends Launcher {
|
||||
|
||||
res.addAllWithoutParsing(options.getJavaArguments());
|
||||
|
||||
Charset encoding = StandardCharsets.UTF_8;
|
||||
Charset encoding = OperatingSystem.NATIVE_CHARSET;
|
||||
if (options.getJava().getParsedVersion() < JavaVersion.JAVA_8) {
|
||||
try {
|
||||
String fileEncoding = res.addDefault("-Dfile.encoding=", encoding.name());
|
||||
if (fileEncoding != null)
|
||||
encoding = Charset.forName(fileEncoding.substring("-Dfile.encoding=".length()));
|
||||
} catch (Throwable ex) {
|
||||
encoding = OperatingSystem.NATIVE_CHARSET;
|
||||
LOG.log(Level.WARNING, "Bad file encoding", ex);
|
||||
}
|
||||
} else {
|
||||
res.addDefault("-Dfile.encoding=", "UTF-8");
|
||||
if (options.getJava().getParsedVersion() > JavaVersion.JAVA_17
|
||||
&& VersionNumber.VERSION_COMPARATOR.compare(repository.getGameVersion(version).orElse("1.13"), "1.13") < 0) {
|
||||
res.addDefault("-Dfile.encoding=", "COMPAT");
|
||||
}
|
||||
|
||||
try {
|
||||
String stdoutEncoding = res.addDefault("-Dsun.stdout.encoding=", encoding.name());
|
||||
if (stdoutEncoding != null)
|
||||
encoding = Charset.forName(stdoutEncoding.substring("-Dsun.stdout.encoding=".length()));
|
||||
} catch (Throwable ex) {
|
||||
encoding = OperatingSystem.NATIVE_CHARSET;
|
||||
LOG.log(Level.WARNING, "Bad stdout encoding", ex);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user