code: @Override
      public void writeString(String string) {
          final byte[] encoded = encodeString(string);
          final int len = encoded.length;
          if (len < AMF.LONG_STRING_LENGTH) {
              buf.put(AMF.TYPE_STRING);
              // write unsigned short
              buf.put((byte) ((len >> 8) & 0xff));
              buf.put((byte) (len & 0xff));
          } else {
              buf.put(AMF.TYPE_LONG_STRING);
              buf.putInt(len);
          }
          buf.put(encoded);
      }
docs: {@inheritDoc}