Class StringEncoder
- java.lang.Object
-
- org.apache.logging.log4j.core.util.StringEncoder
-
public final class StringEncoder extends Object
Encodes Strings to bytes.- Since:
- 2.5
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
encodeIsoChars(CharSequence charArray, int charIndex, byte[] byteArray, int byteIndex, int length)
static byte[]
encodeSingleByteChars(CharSequence s)
Encodes the specified char sequence by casting each character to a byte.static int
encodeString(CharSequence charArray, int charOffset, int charLength, byte[] byteArray)
static byte[]
toBytes(String str, Charset charset)
Converts a String to a byte[].
-
-
-
Method Detail
-
toBytes
public static byte[] toBytes(String str, Charset charset)
Converts a String to a byte[].- Parameters:
str
- if null, return null.charset
- if null, use the default charset.- Returns:
- a byte[]
-
encodeSingleByteChars
public static byte[] encodeSingleByteChars(CharSequence s)
Encodes the specified char sequence by casting each character to a byte.- Parameters:
s
- the char sequence to encode- Returns:
- the encoded String
- See Also:
- LOG4J2-1151
-
encodeIsoChars
public static int encodeIsoChars(CharSequence charArray, int charIndex, byte[] byteArray, int byteIndex, int length)
-
encodeString
public static int encodeString(CharSequence charArray, int charOffset, int charLength, byte[] byteArray)
-
-