*buf = encoding_byte[step - 2];
*buf = (unsigned char) (~0xff >> step);
utf8_encode (char *buf, int val){  char *startp = buf;  int retval;  if (val < 0x80)    {      *buf++ = (char) val;      retval = 1;    }  else    {      int step;      for (step = 2; step < 6; ++step)	if ((val & encoding_mask[step - 2]) == 0)	  break;      retval = step;      *buf = encoding_byte[step - 2];      --step;      do	{	  buf[step] = 0x80 | (val & 0x3f);	  val >>= 6;	}      while (--step > 0);      *buf |= val;    }  return buf - startp;}