Example #1
0
  private static void checkSurrogatePair(CharSequence value, int offset, int len) {
    char hi = value.charAt(offset);
    if (len <= offset)
      throw new RuntimeException(
          String.format("Character sequence ends with single surrogate character: 0x%X", hi));

    char lo = value.charAt(offset + 1);
    if (!Character.isSurrogatePair(hi, lo))
      throw new RuntimeException(String.format("Malformed surrogate pair: 0x%X - 0x%X", hi, lo));
  }