in reply to length in bytes of utf8 string

Using Perl 5.8.0 on a SuSE Linux system, I get "2" printed by both versions of the test (hard-coded wide character, and piping a 2-byte utf8 code into stdin).

In what sense have you made sure that stdin is actually receiving two bytes of character data (not counting the line termination)? I did it as follows:

perl -e 'binmode( STDOUT, ":utf8" ); print "\x{00A1}\n";' | perl -e 'use utf8; binmode(STDIN,":utf8"); $x=<>; $x=~s/[\r\n+]//; use bytes; print length($x),$/;'
and this gave me the correct answer (2).

Replies are listed 'Best First'.
Re: Re: length in bytes of utf8 string
by zby (Vicar) on Jun 27, 2003 at 09:03 UTC
    5.8.0 on cygwin - the same.