Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Unicode file

by anu_1 (Acolyte)
on Feb 17, 2011 at 17:34 UTC ( #888761=perlquestion: print w/replies, xml ) Need Help??

anu_1 has asked for the wisdom of the Perl Monks concerning the following question:

Is there any way to read unicode file in Perl 5.6 . The following method gave error in the open syntax open my $fh, "< :encoding(UTF-8)", $filename or die "open: $!"; Thanks for help

Replies are listed 'Best First'.
Re: Unicode file
by moritz (Cardinal) on Feb 18, 2011 at 09:08 UTC

    I'm not familiar with 5.6 (come on, 5.6.0 is 11 years old, in the world of software engineering that's like half a century), but if IO layers don't work, maybe Encode::decode works.

Re: Unicode file
by Khen1950fx (Canon) on Feb 17, 2011 at 18:11 UTC
    open my $fh, '<:utf8', $filename or die $!; should work for you.

      To my (fuzzy) recollection, PerlIO wasn't used in 5.6 unless you explicitly selected to compile it in. It was still experimental. The same reason one doesn't work should prevent the other from working. I could very well be wrong, so I look forward to hearing why you think it should work.

      In the meantime, 5.6 is being installed :) (Upd: IPC::SysV fails, and I'll too lazy to address that. )

        From Perl 5.6.2's Configure:

        Previous version of perl5 used the standard IO mechanisms as defined in <stdio.h>. Versions 5.003_02 and later of perl allow alternate IO mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still the default. This abstraction layer can use AT&T's sfio (if you already have sfio installed) or regular stdio. Using PerlIO with sfio may cause problems with some extension modules. Using PerlIO with stdio is safe, but it is slower than plain stdio and therefore is not the default.

        If this doesn't make any sense to you, just accept the default 'n'. Use the experimental PerlIO abstraction layer? [n]

        The default build doesn't support PerlIO, and thus doesn't support PerlIO layers (e.g. :encoding, :utf8, etc).

        ...just tried it.  Perl 5.6.0 says:

        Unknown open() mode '<:utf8' at ...

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://888761]
Approved by moritz
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2022-05-20 17:43 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (75 votes). Check out past polls.