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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to