code: public static StringBuffer reverse(StringBuffer source) {
          int length = source.length();
          StringBuffer result = new StringBuffer(length);
          for (int i = length; i-- > 0;) {
              char ch = source.charAt(i);
              if (isTrailSurrogate(ch) && i > 0) {
                  char ch2 = source.charAt(i - 1);
                  if (isLeadSurrogate(ch2)) {
                      result.append(ch2);
                      result.append(ch);
                      --i;
                      continue;
                  }
              }
              result.append(ch);
          }
          return result;
      }
docs: Reverses a UTF16 format Unicode string and replaces source's content with it. This method
  will reverse surrogate characters correctly, instead of blindly reversing every character.
  <p>
  Examples:<br>
  UTF16.reverse(new StringBuffer( "Supplementary characters \ud800\udc00\ud801\udc01"))<br>
  returns "\ud801\udc01\ud800\udc00 sretcarahc yratnemelppuS".
  
  @param source The source StringBuffer that contains UTF16 format Unicode string to be reversed
  @return a modified source with reversed UTF16 format Unicode string.