Class EncodingUtil

java.lang.Object
com.itextpdf.commons.utils.EncodingUtil

public final class EncodingUtil extends Object
This file is a helper class for internal usage only. Be aware that its API and functionality may be changed in future.
  • Method Details

    • convertToBytes

      public static byte[] convertToBytes (char[] chars, String encoding) throws CharacterCodingException
      Converts to byte array an array of chars, taking the provided encoding into account.
      Parameters:
      chars - an array of chars to be converted to bytes
      encoding - the encoding to be taken into account while converting the provided array of chars
      Returns:
      the resultant array of bytes
      Throws:
      CharacterCodingException - if anything goes wrong while encoding
    • convertToString

      public static String convertToString (byte[] bytes, String encoding) throws UnsupportedEncodingException
      Converts to String an array of bytes, taking the provided encoding into account.
      Parameters:
      bytes - an array of bytes to be converted to String
      encoding - the encoding to be taken into account while converting the provided bytes
      Returns:
      the resultant string
      Throws:
      UnsupportedEncodingException - if anything goes wrong while encoding