/* Convert a sequence of nibbles to a string of ASCII characters corresponding to the hex digits in those nibbles.  */
static gchar* bin2hex(const guint8 *bin, enum bin2hex_enum type, guint32 len)
/* Convert a sequence of nibbles to a string of ASCII characters corresponding to the hex digits in those nibbles.  */
static gchar* bin2hex(const guint8 *bin, enum bin2hex_enum type, guint32 len)
{
  gchar* ret;
  guint8 ch;
  const guint8* str = bin;
  guint32 size = len;
  gchar* buff;
  ret = (gchar *)wmem_alloc(wmem_packet_scope(), size + 1);
  buff = ret;
  if(type == TYPE_BCD)
  {
    if(size % 2)
    {
      ch = *str & 0x0f;
      *buff++ = NIBBLE_2_ASCHEX(ch);
      str++;
      size--;
    }
    size = len/=2;
  }
  while(size-- > 0)
  {
    ch = (*str >> 4) & 0x0f;
    *buff++ = NIBBLE_2_ASCHEX(ch);
    ch = *str & 0x0f;
    *buff++ = NIBBLE_2_ASCHEX(ch);
    str++;
  }
  *buff = '\0';
  return ret;
}