-
Notifications
You must be signed in to change notification settings - Fork 909
[Bugfix] 修复 #6348 资源包管理处理非UTF-8编码的options.txt文件时出错
#6351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,12 +17,16 @@ | |
| */ | ||
| package org.jackhuang.hmcl.util; | ||
|
|
||
| import org.glavo.chardet.UniversalDetector; | ||
| import org.jackhuang.hmcl.util.gson.JsonUtils; | ||
| import org.jackhuang.hmcl.util.platform.OperatingSystem; | ||
| import org.jetbrains.annotations.Contract; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| import java.io.PrintWriter; | ||
| import java.io.StringWriter; | ||
| import java.nio.charset.Charset; | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.*; | ||
| import java.util.function.Predicate; | ||
| import java.util.regex.Matcher; | ||
|
|
@@ -630,6 +634,17 @@ public static List<String> deserializeStringList(String json) { | |
| return JsonUtils.fromNonNullJson(json, JsonUtils.listTypeOf(String.class)); | ||
| } | ||
|
|
||
| public static Charset detectMaybeNativeTextEncoding(byte[] data) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Add AGENTS.md reference: AGENTS.md:L5-L9 Useful? React with 👍 / 👎. |
||
| var detector = new UniversalDetector(); | ||
| detector.handleData(data); | ||
| detector.dataEnd(); | ||
| var detected = detector.getDetectedCharset(); | ||
| if (detected == null || !detected.isSupported()) return OperatingSystem.NATIVE_CHARSET; | ||
| var charset = detected.getCharset(); | ||
| if (charset == StandardCharsets.UTF_8 || charset == StandardCharsets.US_ASCII) return StandardCharsets.UTF_8; | ||
| return OperatingSystem.NATIVE_CHARSET; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 无需担心,这种情况MC也读取不了,就不管了(
ToobLac marked this conversation as resolved.
|
||
| } | ||
|
|
||
| public static class LevCalculator { | ||
| private int[][] lev; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a
///Markdown-Javadoc comment describing this field’s lifecycle and fallback behavior. This newly introduced field is not documented, and the repository requires documentation for every field and mandates the///format.AGENTS.md reference: AGENTS.md:L16-L20
Useful? React with 👍 / 👎.