www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18632] New: enable use of fromStringz with char[n]

https://issues.dlang.org/show_bug.cgi?id=18632

          Issue ID: 18632
           Summary: enable use of fromStringz with char[n]
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: elpenguino+D gmail.com

i.e.

```
char[40] cString;
auto someString = cString.fromStringz();

assert((someString.length >= 0) && (someString.length <= 40));
```

This would behave more like strnlen than strlen, and would be particularly
useful when the maximum size of the string is known ahead of time.

This would possibly also have the benefit of being  safe and pure.

--
Mar 19 2018