[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: format() with string of length >= 100 containing '\0'
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 03 Aug 2000 16:33:41 -0300
> In the Lua Reference manual is written that format() can only be used
> with strings that don't contain '\0'.
> For this reason, I use format("%s") to cut the characters following the
> first '\0' from a string.
You should not do that. The meaning of "can only be used with strings that
don't contain '\0'" is that you should not use it with strings that do
If you want to cut the characters following the first '\0' from a string,
you can use the following code:
s = gsub(s, "%z.*$", "")
(I assume you want to cuts also the \0 itself...)