Re: length in bytes not characters

2008-01-12 Thread reader
"Chas. Owens" <[EMAIL PROTECTED]> writes: > As you can see it is normal Perl. The real magic happens inside the > length and other functions. They check the value of the hints global > variable ($^H) and change their behavior if the "use bytes" bit is > set. In Perl 5.10 we have been given the

Re: length in bytes not characters

2008-01-12 Thread Chas. Owens
On Jan 12, 2008 1:50 PM, <[EMAIL PROTECTED]> wrote: > Rob Dixon <[EMAIL PROTECTED]> writes: > > > which outputs "char<19>". > > > > If you're hoping for something different from this then perhaps you > > would let us know. > > Sorry if I was unclear as to what I was after. Yes that was it. > > > '

Re: length in bytes not characters

2008-01-12 Thread reader
"Chas. Owens" <[EMAIL PROTECTED]> writes: > It is important to note that this returns the number of characters, > not the number of bytes (in this case they are the same since all of > the UTF-8 characters in your string take up only one byte). You need > to use the bytes pragma to force length t

Re: length in bytes not characters

2008-01-12 Thread reader
Rob Dixon <[EMAIL PROTECTED]> writes: > which outputs "char<19>". > > If you're hoping for something different from this then perhaps you > would let us know. Sorry if I was unclear as to what I was after. Yes that was it. > 'bytes' is a pragma, and documentation on it can be retrieved in the >

Re: length in bytes not characters

2008-01-12 Thread Chas. Owens
On Jan 12, 2008 12:29 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: snip > My best guess at what you're looking for is the total number of bytes in > all the elements of an array. This can be achieved by manually > accumulating the lengths: > >use strict; >use warnings; > >my @ar = qw(one tw

Re: length in bytes not characters

2008-01-12 Thread Rob Dixon
[EMAIL PROTECTED] wrote: How do we get the length of a variable in bytes? I see the length function returns length in characters. unless you (From perldoc -f length): use "do { use bytes; length(EXPR) }" Nothing there would seem to indicate it cannot be used to get the length in cha

length in bytes not characters

2008-01-12 Thread reader
How do we get the length of a variable in bytes? I see the length function returns length in characters. unless you (From perldoc -f length): use "do { use bytes; length(EXPR) }" Nothing there would seem to indicate it cannot be used to get the length in characters or bytes of an array