Package org.apache.jena.atlas.io
Class BlockUTF8
- java.lang.Object
-
- org.apache.jena.atlas.io.BlockUTF8
-
public class BlockUTF8 extends java.lang.ObjectConvert between bytes and chars, UTF-8 only. This code is just the UTF-8 encoding rules - it does not check for legality of the Unicode data. The standard codec do, so do not round-trip with binary compatibility. (Example: a single element of a surrogate pair will be encoded/decoded without lost. The usual Charset encoders/decoders can be expensive to start up - they are also not thread safe. Sometimes we want to convert 10's of chars and UTF-8 can be done in code with no lookup tables (which, if used, are cache-unfriendly). This code is thread safe. It uses code in the hope that JITting will make it fast if used heavily.
-
-
Constructor Summary
Constructors Constructor Description BlockUTF8()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidfromChars(java.lang.CharSequence cs, java.nio.ByteBuffer bb)static voidfromChars(java.nio.CharBuffer cb, java.nio.ByteBuffer bb)Convert characters to UTF-8 bytes in the ByteBuffer.static voidtoChars(java.nio.ByteBuffer bb, java.nio.CharBuffer cb)Convert the bytes in the ByteBuffer to characters in the CharBuffer.static java.lang.StringtoString(java.nio.ByteBuffer bb)Make a string from UTF-8 bytes in a ByteBuffer
-
-
-
Method Detail
-
toChars
public static void toChars(java.nio.ByteBuffer bb, java.nio.CharBuffer cb)Convert the bytes in the ByteBuffer to characters in the CharBuffer. The CharBuffer must be large enough.
-
fromChars
public static void fromChars(java.nio.CharBuffer cb, java.nio.ByteBuffer bb)Convert characters to UTF-8 bytes in the ByteBuffer. The ByteBuffer must be large enough.
-
toString
public static java.lang.String toString(java.nio.ByteBuffer bb)
Make a string from UTF-8 bytes in a ByteBuffer
-
fromChars
public static void fromChars(java.lang.CharSequence cs, java.nio.ByteBuffer bb)
-
-