Package com.helger.base.string
Class StringEncoding
java.lang.Object
com.helger.base.string.StringEncoding
-
Method Summary
Modifier and TypeMethodDescriptionstatic char[]decodeBytesToChars(byte[] aByteArray, int nOfs, int nLen, Charset aCharset) Decode a byte array to a char array using the provided charset.static char[]decodeBytesToChars(byte[] aByteArray, Charset aCharset) Decode a byte array to a char array using the provided charset.static byte[]encodeCharToBytes(char[] aCharArray, int nOfs, int nLen, Charset aCharset) Encode a char array to a byte array using the provided charset.static byte[]encodeCharToBytes(char[] aCharArray, Charset aCharset) Encode a char array to a byte array using the provided charset.
-
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 asnew String (aCharArray).getBytes (aCharset)just without the intermediate objects.- Parameters:
aCharArray- The char array to be encoded. May not benull.aCharset- Charset to be used. May not benull.- 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 asnew String (aCharArray).getBytes (aCharset)just without the intermediate objects.- Parameters:
aCharArray- The char array to be encoded. May not benull.nOfs- Offset into char array. Must be ≥ 0.nLen- Chars to encode. Must be ≥ 0.aCharset- Charset to be used. May not benull.- 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 asnew String (aByteArray, aCharset)just without the intermediate objects.- Parameters:
aByteArray- The byte array to be decoded. May not benull.aCharset- Charset to be used. May not benull.- 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 asnew String (aByteArray, aCharset)just without the intermediate objects.- Parameters:
aByteArray- The byte array to be decoded. May not benull.nOfs- Offset into byte array. Must be ≥ 0.nLen- Bytes to encode. Must be ≥ 0.aCharset- Charset to be used. May not benull.- Returns:
- The created char array. Never
null. - Since:
- 8.6.4
-