code: private int writeNewString(String object, boolean unshared) throws IOException {
          long count = ModifiedUtf8.countBytes(object, false);
          byte[] buffer;
          int offset = 0;
          if (count <= 0xffff) {
              buffer = new byte[1 + SizeOf.SHORT + (int) count];
              buffer[offset++] = TC_STRING;
              Memory.pokeShort(buffer, offset, (short) count, ByteOrder.BIG_ENDIAN);
              offset += SizeOf.SHORT;
          } else {
              buffer = new byte[1 + SizeOf.LONG + (int) count];
              buffer[offset++] = TC_LONGSTRING;
              Memory.pokeLong(buffer, offset, count, ByteOrder.BIG_ENDIAN);
              offset += SizeOf.LONG;
          }
          ModifiedUtf8.encode(buffer, offset, object);
          output.write(buffer, 0, buffer.length);
  
          int handle = nextHandle();
          if (!unshared) {
              objectsWritten.put(object, handle);
          }
  
          return handle;
      }
docs: Write String {@code object} into the receiver. It is assumed the
  String has not been dumped yet. Returns the handle for this object (String) which is dumped here.
  Strings are saved encoded with {@link DataInput modified UTF-8}.
  
  @param object
  the string to dump.
  @return the handle assigned to the String being dumped
  
  @throws IOException
  If an IO exception happened when writing the String.