Class CharsetEncodingUtils


  • public class CharsetEncodingUtils
    extends java.lang.Object
    Utility class related to encoding characters into (UTF-8) byte sequences.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] encodeAsUTF8​(java.lang.String input)
      Like String.getBytes(java.nio.charset.Charset) (with "UTF-8"), except that encoding problems (like unpaired surrogates) are reported as exceptions (see CodingErrorAction.REPORT, instead of being silently replaces as it would happen otherwise.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • encodeAsUTF8

        public static byte[] encodeAsUTF8​(java.lang.String input)
                                   throws java.io.IOException
        Like String.getBytes(java.nio.charset.Charset) (with "UTF-8"), except that encoding problems (like unpaired surrogates) are reported as exceptions (see CodingErrorAction.REPORT, instead of being silently replaces as it would happen otherwise.
        Parameters:
        input - String to encode
        Returns:
        String encoded using StandardCharsets.UTF_8
        Throws:
        java.io.IOException - on encoding error