You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "alhudz (via GitHub)" <gi...@apache.org> on 2026/06/24 15:43:32 UTC

[PR] keep StrBuilder.reverse from splitting surrogate pairs [commons-lang]

alhudz opened a new pull request, #1730:
URL: https://github.com/apache/commons-lang/pull/1730

   `Repro:` `new StrBuilder("a" + "😀" + "b").reverse()` returns `b\uDE00\uD83Da` (a low surrogate ahead of its high surrogate), where `new StringBuilder(...).reverse()` returns `b😀a`.
   `Cause:` `reverse()` swaps the buffer one `char` at a time, so every surrogate pair is left in low-high order and the supplementary code point becomes malformed UTF-16.
   `Fix:` after the char swap, walk the buffer once and swap each adjacent low-high surrogate pair back to high-low, matching `StringBuilder`/`StringBuffer` which this class is documented to mimic. BMP text, lone surrogates and odd-length buffers are untouched.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep StrBuilder.reverse from splitting surrogate pairs [commons-lang]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #1730:
URL: https://github.com/apache/commons-lang/pull/1730#issuecomment-4803418052

   Hello @alhudz , the CI is running... please port to Apache Commons Text as this class is deprecated here. TY!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep StrBuilder.reverse from splitting surrogate pairs [commons-lang]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #1730:
URL: https://github.com/apache/commons-lang/pull/1730


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep StrBuilder.reverse from splitting surrogate pairs [commons-lang]

Posted by "alhudz (via GitHub)" <gi...@apache.org>.
alhudz commented on PR #1730:
URL: https://github.com/apache/commons-lang/pull/1730#issuecomment-4815503199

   Done — ported to Commons Text in apache/commons-text#756, same surrogate-pair restore on `TextStringBuilder.reverse`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org