Skip to content

Conversation

@malkovitc
Copy link

Summary

Fixes #646

Improve Data(hexString:) to handle edge cases more robustly:

  • Reject odd-length strings - returns nil for strings like "012" that can't be valid hex
  • Support optional 0x prefix - accepts both 0x and 0X prefixes
  • Trim whitespace - handles leading/trailing spaces gracefully
  • Handle empty strings - returns empty Data for empty input

Changes

  • Updated Data(hexString:) in BinaryEncodingUtils.swift
  • Added comprehensive unit tests in HexStringTests.swift (17 test cases)

Test plan

  • All new hex parsing tests pass
  • Existing tests still pass
  • Manual verification of hex parsing in packet handling

evgeniy.chernomortsev added 2 commits December 9, 2025 14:50
allowBluetoothHFP is not available on iOS Simulator, causing build
failures. Use conditional compilation to exclude this option when
building for simulator while keeping it for device builds.
Improve Data(hexString:) to handle edge cases:
- Reject odd-length strings (return nil)
- Support optional 0x/0X prefix
- Trim leading/trailing whitespace
- Handle empty strings correctly

Add comprehensive unit tests for hex parsing.
@malkovitc malkovitc closed this by deleting the head repository Dec 10, 2025
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.

Improvement: Harden and reuse hex parsing across the codebase

1 participant