Package se.datadosen.util
Class StringCodec
java.lang.Object
se.datadosen.util.StringCodec
Convert Strings to and from byte array representation with auto detecting and
marking of UTF-8 and UTF-16 encodings. This class is under LGPL licence
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondecode
(byte[] buf) decode
(byte[] buf, int offset, int length) byte[]
byte[]
boolean
Decide if this class is to add signature byte sequence indicating UTF-8 and UTF-16 Default is to not add signaturestatic boolean
isEncodable
(String s, String encoding) static boolean
isUTF8
(byte[] buf) static boolean
isUTF8
(byte[] buf, int offset, int length) void
setAddSignature
(boolean addIt)
-
Field Details
-
encMap
-
-
Constructor Details
-
StringCodec
public StringCodec()
-
-
Method Details
-
isAddSignature
public boolean isAddSignature()Decide if this class is to add signature byte sequence indicating UTF-8 and UTF-16 Default is to not add signature -
setAddSignature
public void setAddSignature(boolean addIt) -
encode
- Throws:
UnsupportedEncodingException
-
encode
- Throws:
UnsupportedEncodingException
-
decode
- Throws:
UnsupportedEncodingException
-
decode
- Throws:
UnsupportedEncodingException
-
decode
- Throws:
UnsupportedEncodingException
-
decode
public String decode(byte[] buf, int offset, int length, String defaultEncoding) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
isUTF8
public static boolean isUTF8(byte[] buf) -
isUTF8
public static boolean isUTF8(byte[] buf, int offset, int length) -
getDetectedEncoding
-
isEncodable
- Throws:
UnsupportedEncodingException
-