Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3286

DefaultGroovyMethods#reverse(String) does not reverse strings correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.7, 1.6-rc-1
    • 1.6.4, 1.7-beta-1
    • groovy-jdk
    • None
    • Patch

    Description

      The current implementation does not handle Unicode surrogate pairs. It fails for characters outside the BMP.

      Here's a patch for the bug:

          public static String reverse(String self) {
              return new StringBuilder(self).reverse().toString();
          }
      

      Attachments

        Activity

          People

            paulk Paul King
            veita Alexander Veit
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: