Package com.itextpdf.commons.utils
Class EncodingUtil
java.lang.Object
com.itextpdf.commons.utils.EncodingUtil
This file is a helper class for internal usage only. Be aware that its API and functionality may be changed in future.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
convertToBytes
(char[] chars, String encoding) Converts to byte array an array of chars, taking the provided encoding into account.static String
convertToString
(byte[] bytes, String encoding) Converts to String an array of bytes, taking the provided encoding into account.
-
Method Details
-
convertToBytes
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
-