Use UTF-8 instead of ASCII for character data at lexical levels 0 and 1#5
Merged
Merged
Conversation
Change ConvertCharacterData in Iso8211FieldReader to use Encoding.UTF8 instead of Encoding.ASCII for lexical levels below 2. This fixes decoding of UTF-8 encoded text (e.g. French accented characters like Île d'Orléans) in real-world S-101 datasets. UTF-8 is backward-compatible with ASCII so existing pure-ASCII data continues to decode identically. Add tests verifying ASCII regression and UTF-8 decoding at levels 0 and 1. Co-authored-by: Copilot <223556219+Copilot@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.
Problem
ConvertCharacterDatainIso8211FieldReader.csusesEncoding.ASCIIfor lexical levels 0 and 1, which replaces any byte above 127 with?. Real-world S-101 datasets (e.g., Canadian Hydrographic Service) encode French accented characters in UTF-8, so text likeÎle d'Orléansis decoded as??le d'Orl??ans.Fix
Changed
Encoding.ASCII→Encoding.UTF8in theConvertCharacterDatamethod. This is safe because:Tests
Added 3 new tests to
Iso8211FieldReaderTests.cs:Île d'Orléansdecodes correctly at lexical level 0Île d'Orléansdecodes correctly at lexical level 1All 54 field reader tests pass.