public static @Nullable String tryDecodeString(byte @NotNull [] bytes, final @NotNull Charset charset) {
    try {
      int bomLength = getBOMLength(bytes, charset);
      ByteBuffer buffer = ByteBuffer.wrap(bytes, bomLength, bytes.length - bomLength);
      CharsetDecoder decoder = charset.newDecoder()
        .onMalformedInput(CodingErrorAction.REPORT)
        .onUnmappableCharacter(CodingErrorAction.REPORT);
      return decoder.decode(buffer).toString();
    }
    catch (CharacterCodingException e) {
      return null;
    }
  }
public static @Nullable String tryDecodeString(byte @NotNull [] bytes, final @NotNull Charset charset)