fix: Transliterate retries with larger buffer on overflow (#159)#223
Open
imnasnainaec wants to merge 8 commits into
Open
fix: Transliterate retries with larger buffer on overflow (#159)#223imnasnainaec wants to merge 8 commits into
imnasnainaec wants to merge 8 commits into
Conversation
…#159) Characters that expand dramatically during transliteration (e.g. U+FDFA ﷺ) previously caused an immediate OverflowException when the default multiplier was too small. The method now retries once with a doubled buffer before throwing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
On BUFFER_OVERFLOW_ERROR, utrans_transUChars updates textLength to the actual number of UChars required, so use that directly rather than doubling the current capacity. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use Max(textLength, textCapacity * 2) on retry so the buffer is always at least doubled even if ICU reports a partial output length. Update Transliterate_Overflow test to assert success rather than OverflowException, since the retry now handles the case correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Assert exact output value in Transliterate_Overflow (not just non-empty) - Add test for multiple high-expansion chars with multiplier=1 - Add test for empty string input Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ermshiperete
approved these changes
Jun 9, 2026
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.
Summary
Transliterator.Transliteratenow automatically retries with a doubled buffer when ICU reportsBUFFER_OVERFLOW_ERROR, instead of immediately throwing.Fixes #159 (including the memory leak observed in a comment)
This fix is technically a breaking change, since
Transliterateno longer throws an error in situations it used to...🤖 Generated with Claude Code
This fix is technically a breaking change, since
Transliterateno longer throws an error in situations it used to...Devin review: https://app.devin.ai/review/sillsdev/icu-dotnet/pull/223