If

string test = "abc\0def";
printf("\ntest='%s'", test); // Prints 'abc' -- as expected

and you do strmid on "test" -->> see manual:

count - number of characters in the copy; 1000 characters maximum. If count exceeds the length of str, it is copied until the end.

important here: If count exceeds the length of str, it is copied until the end.


So "test" is abc which is
012
abc

this exceeds the count:

tring mid = strmid(test, 3, 2);
printf("\nmid='%s'", mid); // Prints 'c' -- that appears wrong. Should yield an empty string

string mid = strmid(test, 4, 2);
printf("\nmid='%s'", mid); // Prints 'c' -- that definitely appears wrong. Should print an empty string or 'de'