bit_write_TU (Bit_Chain *restrict dat, BITCODE_TU restrict chain)
{
  unsigned int i;
  unsigned int length;

  if (chain)
    {
#if defined(HAVE_WCHAR_H) && defined(SIZEOF_WCHAR_T) && SIZEOF_WCHAR_T == 2
      length = wcslen (chain) + 1;
#else
      for (length = 0; chain[length]; length++)
        ;
      length++;
#endif
    }
  else
    length = 0;

  bit_write_BS (dat, length);
  for (i = 0; i < length; i++)
    {
      bit_write_RS (dat, chain[i]); // probably without byte swapping
    }
  bit_write_RS (dat, 0); //?? unsure about that
}
bit_write_TU (Bit_Chain *restrict dat, BITCODE_TU restrict chain)
{
  unsigned int i;
  unsigned int length;

  if (chain)
    {
#if defined(HAVE_WCHAR_H) && defined(SIZEOF_WCHAR_T) && SIZEOF_WCHAR_T == 2
      length = wcslen (chain) + 1;
#else
      for (length = 0; chain[length]; length++)
        ;
      length++;
#endif
    }
  else
    length = 0;

  bit_write_BS (dat, length);
  for (i = 0; i < length; i++)
    {
      bit_write_RS (dat, chain[i]);  
    }
  bit_write_RS (dat, 0);  
}