Class StringEncoding

java.lang.Object
com.helger.base.string.StringEncoding

@Immutable public final class StringEncoding extends Object
  • Method Details

    • encodeCharToBytes

      @Nonnull @ReturnsMutableCopy public static byte[] encodeCharToBytes(@Nonnull char[] aCharArray, @Nonnull Charset aCharset)
      Encode a char array to a byte array using the provided charset. This does the same as new String (aCharArray).getBytes (aCharset) just without the intermediate objects.
      Parameters:
      aCharArray - The char array to be encoded. May not be null.
      aCharset - Charset to be used. May not be null.
      Returns:
      The created byte array. Never null.
      Since:
      8.6.4
    • encodeCharToBytes

      @Nonnull @ReturnsMutableCopy public static byte[] encodeCharToBytes(@Nonnull char[] aCharArray, @Nonnegative int nOfs, @Nonnegative int nLen, @Nonnull Charset aCharset)
      Encode a char array to a byte array using the provided charset. This does the same as new String (aCharArray).getBytes (aCharset) just without the intermediate objects.
      Parameters:
      aCharArray - The char array to be encoded. May not be null.
      nOfs - Offset into char array. Must be ≥ 0.
      nLen - Chars to encode. Must be ≥ 0.
      aCharset - Charset to be used. May not be null.
      Returns:
      The created byte array. Never null.
      Since:
      8.6.4
    • decodeBytesToChars

      @Nonnull public static char[] decodeBytesToChars(@Nonnull byte[] aByteArray, @Nonnull Charset aCharset)
      Decode a byte array to a char array using the provided charset. This does the same as new String (aByteArray, aCharset) just without the intermediate objects.
      Parameters:
      aByteArray - The byte array to be decoded. May not be null.
      aCharset - Charset to be used. May not be null.
      Returns:
      The created char array. Never null.
      Since:
      8.6.4
    • decodeBytesToChars

      @Nonnull public static char[] decodeBytesToChars(@Nonnull byte[] aByteArray, @Nonnegative int nOfs, @Nonnegative int nLen, @Nonnull Charset aCharset)
      Decode a byte array to a char array using the provided charset. This does the same as new String (aByteArray, aCharset) just without the intermediate objects.
      Parameters:
      aByteArray - The byte array to be decoded. May not be null.
      nOfs - Offset into byte array. Must be ≥ 0.
      nLen - Bytes to encode. Must be ≥ 0.
      aCharset - Charset to be used. May not be null.
      Returns:
      The created char array. Never null.
      Since:
      8.6.4