code: public static String commonPrefix(final String a, final String b) {
          if (N.isNullOrEmpty(a) || N.isNullOrEmpty(b)) {
              return N.EMPTY_STRING;
          }
  
          int maxPrefixLength = Math.min(a.length(), b.length());
          int p = 0;
  
          while (p < maxPrefixLength && a.charAt(p) == b.charAt(p)) {
              p++;
          }
  
          if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
              p--;
          }
  
          if (p == a.length()) {
              return a.toString();
          } else if (p == b.length()) {
              return b.toString();
          } else {
              return a.subSequence(0, p).toString();
          }
      }
docs: Note: copy rights: Google Guava.
  
  Returns the longest string {@code prefix} such that
  {@code a.toString().startsWith(prefix) && b.toString().startsWith(prefix)}
  , taking care not to split surrogate pairs. If {@code a} and {@code b}
  have no common prefix, returns the empty string.