code: @Nullable
      static Charset guessCharSet(@NotNull final byte[] bytes)
      {
          String[] encodings = { UTF_8, System.getProperty("file.encoding"), ISO_8859_1 };
  
          for (String encoding : encodings)
          {
              Charset charset = Charset.forName(encoding);
              CharsetDecoder cs = charset.newDecoder();
  
              try {
                  cs.decode(ByteBuffer.wrap(bytes));
                  return charset;
              } catch (CharacterCodingException e) {
                  // fall through...
              }
          }
  
          // No encodings succeeded. Return null.
          return null;
      }
docs: Attempts to guess the {@link Charset} of a string provided as a byte array.
  <p>
  Charsets trialled are, in order:
  <ul>
  <li>UTF-8</li>
  <li><code>System.getProperty("file.encoding")</code></li>
  <li>ISO-8859-1</li>
  </ul>
  <p>
  Its only purpose is to guess the Charset if and only if IPTC tag coded character set is not set. If the
  encoding is not UTF-8, the tag should be set. Otherwise it is bad practice. This method tries to
  workaround this issue since some metadata manipulating tools do not prevent such bad practice.
  <p>
  About the reliability of this method: The check if some bytes are UTF-8 or not has a very high reliability.
  The two other checks are less reliable.
  
  @param bytes some text as bytes
  @return the name of the encoding or null if none could be guessed