Skip to content

fix: decode pmset accessory names as MacRoman - #18

Draft
yuchenzhu-research wants to merge 1 commit into
k06a:mainfrom
yuchenzhu-research:agent/fix-bluetooth-macroman-names
Draft

fix: decode pmset accessory names as MacRoman#18
yuchenzhu-research wants to merge 1 commit into
k06a:mainfrom
yuchenzhu-research:agent/fix-bluetooth-macroman-names

Conversation

@yuchenzhu-research

@yuchenzhu-research yuchenzhu-research commented Aug 10, 2026

Copy link
Copy Markdown

Summary

Fix Bluetooth accessory names containing MacRoman characters being rendered as the Unicode replacement character ().

For example:

  • Expected: yuchen’s Magic Keyboard
  • Actual: yuchen�s Magic Keyboard

Root cause

On macOS, pmset -g accps can emit accessory names using MacRoman. Byte 0xD5 represents U+2019 RIGHT SINGLE QUOTATION MARK in MacRoman. macpow decoded the complete stdout buffer with String::from_utf8_lossy, which replaced that byte with U+FFFD.

Changes

  • Preserve valid UTF-8 output unchanged.
  • Fall back to MacRoman decoding when pmset output is not valid UTF-8.
  • Extract Bluetooth output parsing into a testable function.
  • Add regression tests for MacRoman and UTF-8 device names.
  • Apply a behavior-preserving Rust 1.97 Clippy compatibility refactor.

Verification

  • cargo check --release
  • cargo fmt --check
  • cargo test --lib
  • Repository CI Clippy command
  • Regression tests for both MacRoman and UTF-8 names
  • Manual TUI verification: device names render without replacement characters

Closes #19

@yuchenzhu-research yuchenzhu-research changed the title fix(bluetooth): decode pmset accessory names as MacRoman fix: decode pmset accessory names as MacRoman Aug 10, 2026
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.

Bluetooth accessory names with MacRoman apostrophes render as �

1 participant