public Charset guessEncoding(int startOffset, int endOffset, @NotNull Charset defaultCharset) {
    // if the file has a Byte Order Marker, we can assume the file is in UTF-xx
    // otherwise, the file would not be human readable
    Charset charset = guessFromBOM();
    if (charset != null) return charset;
    GuessedEncoding encoding = guessFromContent(startOffset, endOffset);
    switch (encoding) {
      case SEVEN_BIT:
        // if no byte with a high order bit set, the encoding is US-ASCII
        // (it might have been UTF-7, but this encoding is usually internally used only by mail systems)
        // returns the default charset rather than US-ASCII if the enforce8Bit flag is set.
        return enforce8Bit ? defaultCharset : StandardCharsets.US_ASCII;
      case INVALID_UTF8:
        return defaultCharset;
      case VALID_UTF8:
        return StandardCharsets.UTF_8;
      case BINARY:
      default:
        break;
    }
    return null;
  }
public Charset guessEncoding(int startOffset, int endOffset, @NotNull Charset defaultCharset)