code: static ByteBuf encodeString(String str) {
          ByteBuf out = Unpooled.buffer(2);
          byte[] raw;
          try {
              raw = str.getBytes("UTF-8");
              //NB every Java platform has got UTF-8 encoding by default, so this 
              //exception are never raised.
          } catch (UnsupportedEncodingException ex) {
              Log.error("", ex);
              return null;
          }
          //Utils.writeWord(out, raw.length);
          out.writeShort(raw.length);
          out.writeBytes(raw);
          return out;
      }
docs: Return the IoBuffer with string encoded as MSB, LSB and UTF-8 encoded
  string content.