Skip to content

[Bugfix] 修复 #6348 资源包管理处理非UTF-8编码的options.txt文件时出错#6351

Open
ToobLac wants to merge 5 commits into
HMCL-dev:mainfrom
ToobLac:fix/6348
Open

[Bugfix] 修复 #6348 资源包管理处理非UTF-8编码的options.txt文件时出错#6351
ToobLac wants to merge 5 commits into
HMCL-dev:mainfrom
ToobLac:fix/6348

Conversation

@ToobLac

@ToobLac ToobLac commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #6348

@ToobLac ToobLac marked this pull request as ready for review July 9, 2026 08:59
@zhuWin

zhuWin commented Jul 9, 2026

Copy link
Copy Markdown

问题似乎解决了,仍需进一步review

image

@Glavo

Glavo commented Jul 9, 2026

Copy link
Copy Markdown
Member

@codex review

Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/StringUtils.java Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34d122b4b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/StringUtils.java Outdated
@Glavo

Glavo commented Jul 10, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1c167216f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the detected non-UTF-8 charset

When options.txt is encoded in a supported non-UTF-8 charset that differs from the current JVM native charset, such as an instance copied from a GBK Windows machine to a UTF-8 Linux/macOS install or a UTF-16 file with a BOM, this branch discards the charset UniversalDetector found and forces loadOptions() to decode with OperatingSystem.NATIVE_CHARSET. That still produces mojibake before the resource pack lists are parsed and later rewritten, so the non-UTF-8 fix only works when the file happens to match the local native charset; return the detected charset for supported non-ASCII encodings instead of falling back here.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无需担心,这种情况MC也读取不了,就不管了(

Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/StringUtils.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 345 (#6091) 以来的新资源包管理处理非 UTF-8 options.txt 时崩溃

3 participants