On Tue, 24 Jun 2014 13:37:41 -0400, Danyal Zia catofdan...@yahoo.com
wrote:
Hi, I like to print the strings from a C function that returns
const(dchar*), but I can't make the conversion to dstring. I can convert
vice versa by:
dstring text = Hello;
const(dchar)* str =
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer
wrote:
const(dchar *)x = ...;
// assuming 0 terminated
dstring text = x[0..x.strlen].idup;
-Steve
const(dchar)* x = Hello\0;
dstring text = x[0..x.strlen].idup;
writeln(text);
Error: no property 'strlen' for type 'const(dchar)*'
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer
wrote:
// assuming 0 terminated
dstring text = x[0..x.strlen].idup;
strlen is only defined for char, not dchar:
https://github.com/D-Programming-Language/druntime/blob/master/src/core/stdc/string.d#L44
On Tuesday, 24 June 2014 at 18:17:07 UTC, Danyal Zia wrote:
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer
wrote:
const(dchar *)x = ...;
// assuming 0 terminated
dstring text = x[0..x.strlen].idup;
-Steve
const(dchar)* x = Hello\0;
dstring text = x[0..x.strlen].idup;
On Tue, 24 Jun 2014 18:17:06 +, Danyal Zia wrote:
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote:
const(dchar *)x = ...;
// assuming 0 terminated dstring text = x[0..x.strlen].idup;
-Steve
const(dchar)* x = Hello\0;
dstring text = x[0..x.strlen].idup;
On Tuesday, 24 June 2014 at 18:34:31 UTC, Chris Cain wrote:
You can do what he said, but you'll have to write your own
strlen function:
something like:
size_t strlen(in dchar* s) pure @system nothrow
{
size_t pos = 0;
dchar term = '\0';
while(s[pos] != term)
On Tue, 24 Jun 2014 14:28:58 -0400, Chris Cain zsh...@gmail.com wrote:
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote:
// assuming 0 terminated
dstring text = x[0..x.strlen].idup;
strlen is only defined for char, not dchar: