Still, it's gotta be useful to be know how many bytes it occupies. Perhaps
for Content-length headers or something. There are plenty of low level
concepts to think of where one might need this. And even if you can't
think
of any reason now, you don't wanna get hit in the face by it and have to
implement such a function for PHP 6.0.1.
For this type of usage, I'd think it'd be relevant to know how many bytes
the string will occupy in a given output encoding moreso that what it
happens to occupy in the underlying implementation. In the example you
cited, string contents will more typically be sent as utf8 rather than the
utf16 of php's internal encoding.
$utf8str = unicode_encode($unistr, 'utf8');
header('Content-type: text/html; encoding="utf8"');
header('Content-length: ' . strlen($utf8str));
echo $utf8str;
I'm not saying it's impossible that a legitimate use will come up to know
the internal byte-usage of a unicode string, there's certainly no harm in
adding such a function (apart from the tired shot-foot argument). I just
doubt you (or anyone) will come up such a case anytime soon.
-Sara
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php