Fix ISO Latin 1 Encoding/Decoding issues #1219
Merged
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.
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.