Add API(s) for converting pike (wide-) strings to NUL-terminated UTF16-strings.

Currently this is achieved via calling of string_to_unicode(..., 2) and having a special case that ensures that all byte-strings of even length have a double NUL-termination. Eg:

  get_all_args(NULL, args, "%t%T%T.%d%d",
               &username_str, &domain_str, &pw_str,
               &logontype, &logonprovider);

  ref_push_string(username_str);
  push_int(2);
  f_string_to_unicode(2);
  username = (LPCWSTR)STR0(sp[-1].u.string);
  args++;

  if (domain_str) {
    ref_push_string(domain_str);
    push_int(2);
    f_string_to_unicode(2);
    domain = (LPCWSTR)STR0(sp[-1].u.string);
    args++;
  }

It would be nice to have:

  • A function for converting a struct pike_string * to a malloc()ed NUL-terminated UTF16 p_wchar * (eg analogous to fdlib.c:pike_dwim_utf8_to_utf16()).
  • A format (%W?) for get_args()/get_all_args() that returns the above.