With this code :
a$=CHR$(10)+CHR$(13)+CHR$(0)+"J"
a%=INSTR(a$,"J")
DEBUG a%+"\n"
a% returns -1...
both, replace and instr use a highly optimized function to find a string in a string. I would have to change that to work with '\0' characters and fear performance impacts. Do you really need that?
Hmmm - I think it would be best to allow CHR$(0) for INSTR and REPLACE mainly if data is used that contains it.
OK, I'll do my very best.
That'll be great, thanks!
If you don't need to preserve the Null character (and speed isn't that important, or you have small strings!), you could always strip your strings ahead of time using something like (replaces all ascii '0' with ascii '1'): (Not tested)
FUNCTION String_ReplaceNulls$: string$
LOCAL ix%
FOR ix = 0 TO LEN(string$) - 1
IF ASC(MID$(string$, ix, 1)) = 0 THEN string$ = MID$(string$, 0, ix-1) + CHR$(1) + MID$(string$, ix+1)
NEXT
RETURN string$
ENDFUNCTION
Also, MID$ doesn't work in reverse like some BASIC languages? Such as:
IF . . . THEN MID$(string$, ix, 1) = CHR$(1)
If modifying INSTR$ and REPLACE$ to fix this slows these commands down, perhaps adding two new functions may be better?
(INSTRB$, REPLACEB$ or something (B for Bytes like other languages), although the non 'B' versions usually offer non-case sensitive options).
Just some ideas.