[Israel.pm] Unicode problem

Peter Gordon peter at pg-consultants.com
Sun Jun 28 01:33:51 PDT 2009


So, how do I convince the Perl parser to process $p in the same way that
it has processed $x?

I have tried a number of eval combinations and utf encode/decoding
combinations. If there is a way, I have missed it.

Peter



On Sun, 2009-06-28 at 10:15 +0300, Gaal Yahas wrote:
> I don't think your problem is specifically related to Unicode. "\040"
> is an escape sequence that expands to character 32 in your charset,
> which is space in both ASCII and UTF-8.
> 
> $x, the value Perl's parser had processed, reflect the string literal.
> $p, the value you read off disk verbatim, does not.
> 
> On Sun, Jun 28, 2009 at 9:00 AM, Peter Gordon<peter at pg-consultants.com> wrote:
> > I have a Unicode string in a program, and a unicode string on in a file,
> > and the strings do not match as equal.
> >
> > In the example below, save the program as file /tmp/a2.pl.
> > Run the program /tmp/a2.pl. The program reads itself and extracts the
> > unicode string.
> >
> > The strings do not match.
> >
> > When displayed, the strings are not the same.
> >
> > What do I need to do to get them to display and match as equal?
> >
> > Thanks,
> >
> > Peter
> >
> >
> > #! /usr/bin/perl
> >
> > use strict ;
> > use warnings ;
> >
> > my $x = "//10.39.43.1/사과를\040좋아해요" ;
> >
> > open(my $fh, "<:utf8", "/tmp/a2.pl");
> > local $/ = undef ;
> > my $y = <$fh> ;
> > close $fh ;
> >
> > my ($p) = $y =~ m!"(//.*?)"! ;
> > print $p,"\n";
> > print $x,"\n";
> >
> > if ($p eq $x) {
> >    print "EQUAL\n" ;
> > } else {
> >    print "NOT EQUAL\n" ;
> > }
> >
> >
> >
> >  DB<1> p $p
> > //10.39.43.1/사과를\040좋아해요
> >  DB<2> p $x
> > //10.39.43.1/사과를 좋아해요
> >  DB<3>
> >
> > _______________________________________________
> > Perl mailing list
> > Perl at perl.org.il
> > http://mail.perl.org.il/mailman/listinfo/perl
> 
> 
> 
> -- 
> Gaal Yahas <gaal at forum2.org>
> http://gaal.livejournal.com/
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl



More information about the Perl mailing list