Front page | perl.perl5.porters |
Postings from September 2010
[perl #77780] sysread returns character count with utf8 file handle
Thread Previous
|
Thread Next
From:
Anno Siegel
Date:
September 11, 2010 00:10
Subject:
[perl #77780] sysread returns character count with utf8 file handle
Message ID:
rt-3.6.HEAD-5116-1284151990-263.77780-75-0@perl.org
# New Ticket Created by Anno Siegel
# Please include the string: [perl #77780]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=77780 >
This is a bug report for perl from anno5@mac.com,
generated with the help of perlbug 1.39 running under perl 5.13.4.
-----------------------------------------------------------------
When sysread() is called on a file handle in utf8 mode, the size
returned is in charcters, not bytes. This contradicts the
documentation (with which I would agree). The snippet below
reads the string "aeiouäöü\n" from a utf8-encoded file. The
file size returned by -s and the size reported by sysread disagree.
It's been run under a relatively recent bleadperl.
my $file = 'with_utf8';
open my $fh, '<', $file or die "$file: $!"; # aeiouäöü
binmode $fh, 'utf8';
# use bytes;
my $size = -s $fh;
my $rc = sysread($fh, my $buffer, $size);
say "sysread: $rc, -s $size";
# prints "sysread: 9, -s 12"
In my opinion, sysread should not depend on encoding or io layers,
and should never return character strings.
Regards, Anno
Sorry if this is a repetition, I had a failed(?) attempt.
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
Site configuration information for perl 5.13.4:
Configured by anno at Mon Aug 30 21:03:28 CEST 2010.
Summary of my perl5 (revision 5 version 13 subversion 4) configuration:
Platform:
osname=darwin, osvers=10.4.0, archname=darwin-2level
uname='darwin radom.local 10.4.0 darwin kernel version 10.4.0: fri apr 23 18:28:53 pdt 2010; root:xnu-1504.7.4~1release_i386 i386 '
config_args='-de -Dprefix=/Users/anno/perl5/perlbrew/perls/bleadperl -Dusedevel'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
optimize='-O3',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include'
ccversion='', gccversion='4.2.1 (Apple Inc. build 5664)', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib -L/opt/local/lib'
libpth=/usr/local/lib /opt/local/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector'
Locally applied patches:
---
@INC for perl 5.13.4:
/Users/anno/lib/perl5
/Users/anno/perl5/perlbrew/perls/bleadperl/lib/site_perl/5.13.4/darwin-2level
/Users/anno/perl5/perlbrew/perls/bleadperl/lib/site_perl/5.13.4
/Users/anno/perl5/perlbrew/perls/bleadperl/lib/5.13.4/darwin-2level
/Users/anno/perl5/perlbrew/perls/bleadperl/lib/5.13.4
.
---
Environment for perl 5.13.4:
DYLD_LIBRARY_PATH (unset)
HOME=/Users/anno
LANG=de_DE.UTF-8
LANGUAGE (unset)
LC_CTYPE=de_DE.UTF-8
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/Users/anno/perl5/perlbrew/bin:/Users/anno/perl5/perlbrew/perls/current/bin:/Users/anno/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/local/bin:/opt/local/sbin:/Users/anno/bin/gmp_factorlib:/usr/local/pgsql/bin
PERL5LIB=/Users/anno/lib/perl5
PERL_BADLANG (unset)
PERL_UNICODE=SDAL
SHELL=/bin/bash
Thread Previous
|
Thread Next