Skip to content

Use invariant case mapping for character set names and the mailto prefix - #641

Open
menes97 wants to merge 1 commit into
micjahn:masterfrom
menes97:fix/culture-invariant-case-mapping
Open

menes97 wants to merge 1 commit into
micjahn:masterfrom
menes97:fix/culture-invariant-case-mapping

Conversation

@menes97

@menes97 menes97 commented Nov 18, 2026

Copy link
Copy Markdown

Under a Turkish culture "i".ToUpper() is the dotted "İ" and "I".ToLower() is the dotless "ı", so culture-sensitive case mapping broke two lookups:

  • CharacterSetECI.getCharacterSetECIByName("iso-8859-1") and getCharacterSetECI(Encoding) upper-cased the name (Encoding.WebName is lower-case) to "İSO-8859-1" and returned null.
  • EmailAddressResultParser lower-cased the text to check for mailto:, so MAILTO:… was no longer recognized and the result type became TEXT.

These three calls now use ToUpperInvariant() / ToLowerInvariant().

Tests (both set the current culture to tr-TR and restore it):

  • CharacterSetECITestCase.Should_Resolve_ECI_Independent_Of_Current_Culture: fails without the change (Expected: not null, But was: null).
  • EmailAddressParsedResultTestCase.testMailtoPrefixIsCultureIndependent: fails without the change (Expected: EMAIL_ADDRESS, But was: TEXT).

What I ran: this machine has no .NET Framework/NUnit 2 setup for the repo's test project, so I compiled the zxing.portable sources with NUnit 4 in a scratch net8.0 project and ran the two new tests and the EmailAddress fixture there: 10 passed. In that setup other ECI tests fail on code pages that .NET 8 doesn't provide without a provider, which I didn't compare against the default branch. Please let CI run the real test project.

QRCodeWriter and a few WebName.ToUpper() calls (StringUtils, ECIEncoderSet, PDF417HighLevelEncoder) have the same pattern; I left them out to keep this change small and can follow up.

Written with Claude Code (AI); I reviewed the change and ran the tests above.

🤖 Generated with Claude Code

ToUpper()/ToLower() depend on the current culture: under tr-TR 'i' maps to a
dotted capital I, so CharacterSetECI could not resolve names like iso-8859-1
and MAILTO: URLs were no longer recognized as e-mail addresses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant