Repository navigation
Settings files: keep madeira.cfg lines that are not UTF-8, and UTF-16 .ini files as UTF-16 - #629
Open
spenstars1 wants to merge 1 commit into
Open
spenstars1 wants to merge 1 commit into
spenstars1 wants to merge 1 commit into
Conversation
… .ini files as UTF-16 madeira.cfg (willfaust#617): a byte that is not UTF-8 no longer hides the whole file from the app. MadeiraConfig.all() decodes it lossily, set() works on bytes like build/madeira_cfg.h and keeps every other line unchanged, and a file that exists but cannot be read is no longer rewritten with only the new key. WineProcessBridge exports the env.* lines of such a file, and Get Help from Claude includes it. Settings files (willfaust#618): a .ini starting with FF FE opens as UTF-16 LE and is saved as UTF-16 LE; a broken UTF-16 file does not open, so it is never saved damaged. Fixes willfaust#617, fixes willfaust#618. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: spenstars1 <356334520+spenstars1@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #617, fixes #618.
madeira.cfg (#617)
A single byte that is not UTF-8 (for example a comment saved as Windows-1252 by a PC editor) made the strict UTF-8 decode fail, so the app treated the file as empty, and the next Settings change rewrote it with only that key.
MadeiraConfig.all()decodes the file lossily (String(decoding:as: UTF8.self)), so Settings sees the same keysbuild/madeira_cfg.happlies.MadeiraConfig.set()works on bytes, as the native reader does. Every other line, including the non-UTF-8 comment, is kept byte for byte. A file that exists but cannot be read returnsfalseand is not rewritten. Line endings are written as LF, as before.WineProcessBridge.mread theenv.*lines withNSUTF8StringEncoding, so such a file exported none of them. It now falls back to Latin 1. Limitation (noted in the code): a non-ASCII env value in such a file is re-encoded rather than passed byte for byte.ClaudeHelp.swift) left such a madeira.cfg out of its files. It now reads the file lossily too.Settings files (#618)
IniFileTextopens a file that starts withFF FEas UTF-16 LE and saves it as UTF-16 LE with its byte order mark. A broken UTF-16 file (odd length) does not open, so it is never saved damaged.Checks
tests/host/check-runtime-settings.py: a madeira.cfg with a Windows-1252 byte and CRLF lines reads its keys, andset()keeps the comment bytes and every other key.tests/host/check-ini-editor.py: a UTF-16 LE file opens with its section and values, round-trips unchanged, saves an edited value as UTF-16 LE, and a broken UTF-16 file does not open.Not run yet: I wrote this on Windows without a Swift toolchain, so only the Python source checks ran (they pass). The Swift parts of the two checks and the Objective-C change still need a run on macOS (
python3 tests/host/check-ini-editor.py --require-swift,python3 tests/host/check-runtime-settings.py). Not tested on a device.The branch merges cleanly with the open PRs that touch these files (#594, #615). #463, #480 and #506 already conflict with main, and this change adds no new conflicts with them.
Written with the help of Claude Code (AI).
🤖 Generated with Claude Code