Skip to content

Transpile str.rstrip - #859

Merged
mristin merged 1 commit into
mainfrom
mristin/Transpile-str.rstrip
Oct 21, 2026
Merged

mristin merged 1 commit into
mainfrom
mristin/Transpile-str.rstrip

Conversation

@mristin

@mristin mristin commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

We transpile text.rstrip(chars) to all the targets. As with lstrip, the characters (code points) are stripped as in Python, never the UTF-16 code units:

common::RStrip(text, chars)                      // C++
Common.StringHelpers.RStrip(text, chars)         // C#
strings.TrimRight(text, chars)                   // Go
StringHelpers.rstrip(text, chars)                // Java
OurCommon.rstrip(text, chars)                    // TypeScript

C++, C# and Java share the check whether a character is among the stripped ones between lstrip and rstrip. The meta-model string_operations checks rstrip on characters which share a surrogate with the stripped ones, e.g., "a😀".rstrip("𐈀😁").

We transpile ``text.rstrip(chars)`` to all the targets. As with
``lstrip``, the characters (code points) are stripped as in Python,
never the UTF-16 code units:

    common::RStrip(text, chars)                      // C++
    Common.StringHelpers.RStrip(text, chars)         // C#
    strings.TrimRight(text, chars)                   // Go
    StringHelpers.rstrip(text, chars)                // Java
    OurCommon.rstrip(text, chars)                    // TypeScript

C++, C# and Java share the check whether a character is among
the stripped ones between ``lstrip`` and ``rstrip``. The meta-model
``string_operations`` checks ``rstrip`` on characters which share
a surrogate with the stripped ones, *e.g.*, ``"a😀".rstrip("𐈀😁")``.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 39665495322

Coverage increased (+0.02%) to 90.174%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 90 of 90 lines across 19 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 51200
Covered Lines: 46169
Line Coverage: 90.17%
Coverage Strength: 2.71 hits per line

💛 - Coveralls

@mristin
mristin merged commit 0f87135 into main Oct 21, 2026
5 checks passed
@mristin
mristin deleted the mristin/Transpile-str.rstrip branch October 21, 2026 20:36
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