java.lang.Object
net.metanotion.io.data.UTF8StringBytes
All Implemented Interfaces:
Serializer<String>

public class UTF8StringBytesextends Object implements Serializer<String>
String serializer using UTF-8 encoding.

Converts between String objects and UTF-8 byte arrays. Supports full Unicode character set for internationalized text.

UTF-8 encoding characteristics:

  • ASCII characters (U+0000 to U+007F) use 1 byte
  • Latin characters with diacritics (U+0080 to U+07FF) use 2 bytes
  • Most common characters including CJK (U+0800 to U+FFFF) use 3 bytes
  • Astral plane characters (U+10000 to U+10FFFF) use 4 bytes
  • Constructor Details

    • UTF8StringBytes

      public UTF8StringBytes()
      The codec holds no state - UTF-8 is named on every call - so a bare instance is ready to serialise.
  • Method Details

    • getBytes

      public byte[] getBytes(String o)
      Description copied from interface: Serializer
      o).
      Specified by:
      getBytes in interface Serializer<String>
      Parameters:
      o - the object to serialize
      Returns:
      the given object's serialized form as a byte array
    • construct

      public String construct(byte[] b)
      Description copied from interface: Serializer
      b).
      Specified by:
      construct in interface Serializer<String>
      Parameters:
      b - the serialized bytes to read back
      Returns:
      the deserialized object