Hmm.. now I need a function that converts a wchar* to a wchar[] or wstring. There doesn't seem to be anything in Phobos for this type of conversion. Or maybe I haven't looked hard enough?
I don't know whether this is safe since I'm not sure how the null terminator is represented in utf16, but it does seem to work ok from a few test cases: wstring fromWStringz(wchar* value) { if (value is null) return ""; auto oldPos = value; uint nullPos; while (*value++ != '\0') { nullPos++; } if (nullPos == 0) return ""; return to!wstring(oldPos[0..nullPos]); } I thought we would pay more attention to interfacing with C code. Since D is supposed to work side-by-side with C, we should have more functions that convert common data types between the two languages.