It is not possible to search for NULL characters using the usearch engine. When
the
pattern consists of a single NULL character, the engine says all positions in
the
text match. Here is a test case:
#include <assert.h>
#include <unicode/utypes.h>
#include <unicode/ustring.h>
#include <unicode/ures.h>
#include <unicode/ucol.h>
#include <unicode/usearch.h>
void main ()
{
UCollator *coll;
UErrorCode ec;
UStringSearch *search;
U_STRING_DECL (pattern, "0", 1);
U_STRING_DECL (text, "IS 0 OK ?", 9);
int pos;
U_STRING_INIT (pattern, "0", 1);
U_STRING_INIT (text, "IS 0 OK ?", 9);
pattern [0] = pattern [1] = 0;
text [3] = 0;
ec=U_ZERO_ERROR;
coll = ucol_open ("en-US", &ec);
assert (U_SUCCESS (ec));
search=usearch_openFromCollator (pattern, 1, text, 9, coll, NULL, &ec);
assert (U_SUCCESS (ec));
for(pos=usearch_first (search, &ec);
pos!=USEARCH_DONE;
pos=usearch_next (search, &ec)) {
printf ("POS: %d %d\n", pos, usearch_getMatchedLength (search));
}
}