toCString - how to get it's length
BlitzMax Forums/BlitzMax Beginners Area/toCString - how to get it's length
| ||
Just another small question: <string>.ToCString:byte ptr() converts a BlitzMax (Unicode) string into a (0-terminated) "C" string - I don't ask how this is done, although that would be interesting as well (UTF-8? just ignoring the high byte?) What I would like to know is how I can get the length of the resulting string: will I have to write a loop myself, looking for the 0-byte? Or is there already a "strlen" command built-in? Thanks in advance for your help |
| ||
I use strlen in some of my modules... but it won't work properly for multi-byte character strings. you will have to "extern" it though, as it's not made available by default. from my database framework: Extern Function _strlen:Int(s:Byte Ptr) = "strlen" End Extern |
| ||
Brucey, that's a brilliant idea! "C" strings aren't multi-byte anyway (otherwise, the $z suffix would be useless). I'll try it immediately - thanks for the trick |