strpos searching for unicode in PHP (and handling inline UTF-8)

purlie

New Member
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-8Part of the problem is I don't know how to specify the code for use in \[code\]strpos\[/code\], and I don't know if PHP has to be compiled with any special support for the code, or if I have to use \[code\]mb_strpos\[/code\] which I am trying to avoid since it also might not be available.ie. for example the needle is \[code\]U+56DE U+590D\[/code\] (without the space)With preg_match it might be \[code\]preg_match("@\x{56DE}\x{590D}@",$haystack)\[/code\]but that actually requires \[code\]@u\[/code\] which might not be available and I get a \[code\]Compilation failed: character value in \x{...} sequence is too large\[/code\] 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 \[code\]U+56DE U+590D\[/code\] 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 ?\[code\]$blah="\u56DE\u590D";\[/code\] doesn't work?Thanks for any ideas!
 
Back
Top