There's no mb_substr_replace() function, so you can't pass a value from mb_strpos() -- ie overloaded strpos() -- and expect it to work. Also, if you use substr() on binary data -- precisely because it's binary safe -- then you really don't want/expect to use mb_substr(). And there's no way to disable this at runtime via ini_set().
I just borrowed a snippet from ZendFramework and applied it to Smarty' s outputfilter.trimwhitespace.
Detecting this and coming up with workarounds is fugly.