I am having a problem dealing with a simple search for a two character unicode string (the needle) inside another string (the haystack) that may or may not be UTF-8
Part of the problem is I don't know how to specify the code for use in strpos
, and I don't know if PHP has to be compiled with any special support for the code, or if I have to use mb_strpos
which I am trying to avoid since it also might not be available.
ie. for example the needle is U+56DE U+590D
(without the space)
With preg_match it might be preg_match("@\x{56DE}\x{590D}@",$haystack)
but that actually requires @u
which might not be available and I get a Compilation failed: character value in \x{...} sequence is too large
anyway.
I don't want to use preg_match anyway as it might be significantly slower than strpos (there are other sequences that have to be searched).
Can I convert U+56DE U+590D
into its single byte sequence (possibly 5-6 characters) and then search for it via strpos? I can't figure out how to convert it to bytes if so.
How do you specify unicode inline in PHP anyway? I mean outside of PRCE ?
$blah="\u56DE\u590D";
doesn't work?
Thanks for any ideas!