Class StringEncoder
java.lang.Object
org.apache.logging.log4j.core.util.StringEncoder
Encodes Strings to bytes.
- Since:
- 2.5
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
encodeIsoChars
(CharSequence charArray, int charIndex, byte[] byteArray, int byteIndex, int length) Deprecated.No longer necessary given better performance in Java 8static byte[]
Deprecated.No longer necessary given better performance in Java 8static int
encodeString
(CharSequence charArray, int charOffset, int charLength, byte[] byteArray) Deprecated.No longer necessary given better performance in Java 8static byte[]
Converts a String to a byte[].
-
Method Details
-
toBytes
Converts a String to a byte[].- Parameters:
str
- if null, return null.charset
- if null, use the default charset.- Returns:
- a byte[]
-
encodeSingleByteChars
Deprecated.No longer necessary given better performance in Java 8Prefer standardString.getBytes(Charset)
which performs better in Java 8 and beyond. 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:
-
encodeIsoChars
@Deprecated public static int encodeIsoChars(CharSequence charArray, int charIndex, byte[] byteArray, int byteIndex, int length) Deprecated.No longer necessary given better performance in Java 8Prefer standardString.getBytes(Charset)
which performs better in Java 8 and beyond. Implementation note: this is the fast path. If the char array contains only ISO-8859-1 characters, all the work will be done here. -
encodeString
@Deprecated public static int encodeString(CharSequence charArray, int charOffset, int charLength, byte[] byteArray) Deprecated.No longer necessary given better performance in Java 8Prefer standardString.getBytes(Charset)
which performs better in Java 8 and beyond.
-