[pve-devel] [PATCH common 1/3] INotify.pm: add binmode utf8 to read/update_file

Dietmar Maurer dietmar at proxmox.com
Fri Aug 24 16:56:48 CEST 2018


BTW, why do you think /etc/hosts may contain utf8 characters? 
Is that defined/documented somewhere?


> On August 24, 2018 at 4:49 PM Dietmar Maurer <dietmar at proxmox.com> wrote:
> 
> 
> NO. Please don't do that!
> 
> I try to avoid that everwhere.
> 
> Instead, Simply call encode/decode where you need it.
> 
> > On August 24, 2018 at 12:34 PM Dominik Csapak <d.csapak at proxmox.com> wrote:
> > 
> > 
> > this reads utf8 characters from files correctly
> > 
> > Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> > ---
> >  src/PVE/INotify.pm | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
> > index 6892b4c..50a1a76 100644
> > --- a/src/PVE/INotify.pm
> > +++ b/src/PVE/INotify.pm
> > @@ -167,7 +167,8 @@ sub update_file {
> >      my $code = sub {
> >  
> >  	$fd = IO::File->new ($filename, "r");
> > -	
> > +	$fd->binmode(':utf8');
> > +
> >  	my $new = &$update($filename, $fd, $data, @args);
> >  
> >  	if (defined($new)) {
> > @@ -232,6 +233,7 @@ sub read_file {
> >      } else {
> >  	$fd = IO::File->new ($filename, "r");
> >      }
> > +    $fd->binmode(':utf8');
> >  
> >      my $acp = $ccinfo->{always_call_parser};
> >  
> > -- 
> > 2.11.0
> > 
> > 
> > _______________________________________________
> > pve-devel mailing list
> > pve-devel at pve.proxmox.com
> > https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list