Package org.webpki.util
Class UTF8
java.lang.Object
org.webpki.util.UTF8
Encodes/decodes UTF-8 data.
-
Method Summary
-
Method Details
-
encode
Encodes Java (UTF-16) String to UTF-8.This method was added because
String.getBytes("utf-8")
does not flag invalid UTF-16.- Parameters:
utf16String
- String presumably holding valid UTF-16- Returns:
- UTF-8 byte array
- Throws:
IllegalArgumentException
-
decode
Decodes a UTF-8 byte array into a String.This method was added because
new String(byteArray, "utf-8")
does not flag invalid UTF-8.- Parameters:
utf8Bytes
- Binary data presumably holding valid UTF-8- Returns:
- Java (UTF-16) String
- Throws:
IllegalArgumentException
-