I have PHP configured with mbstring.func_overload = 7
, so all the single-byte-string functions are mapped to their multi-byte equivalents. But I still sometimes need to treat strings as byte arrays; for example, when calculating their size or doing encryption.
What's the best approach here? Can I just use the multi-byte functions and pass them a single-byte encoding, even though that's not actually how the string is encoded? For example:
mb_substr($utf8str, 0, 1, "latin1");
mb_strlen($utf8str, "latin1");
EDIT: I noticed when looking through PHP's source that they rename the original functions to mb_orig_X, as in mb_orig_strlen. Probably not safe to use, as they're not documented, but interesting.