Skip to content

Fix ISO Latin 1 Encoding/Decoding issues #1219

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

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

jmschonfeld
Copy link
Contributor

As mentioned in #1216, the ISO Latin 1 Encoding/Decoding written natively in swift-foundation does not behave correctly. I accidentally referenced an incorrect code page table when writing the original implementation which limited the supported characters to a subset of those actually supported. In reality, ISO Latin 1 is just the 0x0 through 0xFF unicode code points encoded as single bytes. This means that encoding should simply encode the code point value (and fail for any code point greater than 0xFF) and decoding can simply extend each byte to 16 bits and parse as UTF-16 since all bytes are valid by definition.

This updates the implementation and adds some extra characters to the unit test to validate this behavior.

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit 9ba455d into swiftlang:main Mar 19, 2025
3 checks passed
@jmschonfeld jmschonfeld deleted the fix-iso-latin1 branch March 19, 2025 21:24
jmschonfeld added a commit to jmschonfeld/swift-foundation that referenced this pull request Mar 19, 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.

2 participants