in reply to Re: Re: Re: Size of scalar in bytes
in thread Size of scalar in bytes

In common cases, yes. For example, you can always be sure that ASCII is 8 bits per character (well, 7 really, but nobody stores it like that in practice). It gets a little harder with weird encodings like RAD-50, where each character actually takes 5 and a third bits per character (yup, a non-integer number of bits).

Once you start thinking in terms of Unicode, you should basically give up trying to figure out how many bytes a given character takes. Even UTF-8 encoding allows you to mark a character as having a variable-length number of bits. So unless you're working on the dark internals of handling Unicode, just use bytes (which you should probably have done even if you weren't using Unicode).

If you're intrested, see http://www.sidhe.org/~dan/blog/archives/000255.html.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated