Andrej Mitrovic Wrote: > Actually, this still suffers from the problem when the returned char* > doesn't have a null terminator. It really sucks when C code does that, > and I've just experienced that. There is a solution though: > > Since we can detect the length of the D array passed into > `fromStringz`, we can do the job of to!string ourselves and check for > a null terminator. If one isn't found, we return a string of length 0. > Here's an updated version which doesn't suffer from the missing null > terminator problem:
I do not know the proper action if the string you receive is garbage. Shouldn't it throw an exception since it did not receive a string? This to me seems like a validation issue. If the functions you are calling are expected to return improper data _you_ must validate what your receive, that includes running it through utf validation.
