Programming Windows D Examples are now Online!

Jonathan M Davis jmdavisProg at gmx.com
Tue Jun 21 14:02:57 PDT 2011


On 2011-06-21 13:46, Andrej Mitrovic wrote:
> On 6/21/11, Walter Bright <newshound2 at digitalmars.com> wrote:
> > Fix:
> > char[100] buffer = 0;
> 
> I didn't know about this syntax! I've been under a rock apparently.
> 
> > Fix:
> > char[100] buffer;
> > APIWriteToBuffer(buffer.ptr);
> > 
> > auto p = buffer[0 .. strlen(buffer.ptr)];
> > 
> > myDStringFunction(p);
> 
> Yeah I was going to suggest that. My only problem was I didn't know
> where to look for an strlen equivalent for UTF, but I found it in
> std.utf and it's called stride().

stride isn't a UTF version of strlen. stride returns how many code units it is 
to the beginning of the next code point. You can use it to get the number of 
characters in a string by calling it in a loop, but it isn't a UTF version of 
strlen.

- Jonathan M Davis


More information about the Digitalmars-d-announce mailing list