Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: how to use Encode qw(all)

by almut (Canon)
on Apr 05, 2010 at 15:24 UTC ( #832835=note: print w/replies, xml ) Need Help??


in reply to how to use Encode qw(all)

Depends on what exactly you mean by "input".  If you're referring to data read from an external file, using the PerlIO layer (your latter two variants) is certainly the way to go — except that reading from a file ("<:...") would decode, not encode, as you say in your question; in order to encode you'd need to write to the file...

See also the open pragma, -C and utf8.

Replies are listed 'Best First'.
Re^2: how to use Encode qw(all)
by swilting (Beadle) on Apr 05, 2010 at 15:44 UTC

    I work webmail on @jaos software . incoming (input) are emails

    I thought this little preview of code

    package CGI::as_utf8; BEGIN { use strict; use warnings; use CGI 3.47; # earlier versions have a UTF-8 double-decoding bug { no warnings 'redefine'; my $param_org = \&CGI::param; my $might_decode = sub { my $p = shift; # make sure upload() filehandles are not modified return $p if !$p || ( ref $p && fileno($p) ); utf8::decode($p); # may fail, but only logs an error $p }; *CGI::param = sub { # setting a param goes through the original interface goto &$param_org if scalar @_ != 2; my $q = $_[0]; # assume object calls always my $p = $_[1]; return wantarray ? map { $might_decode->($_) } $q->$param_org($p) : $might_decode->( $q->$param_org($p) ); } } } 1

    but I must be careful in the webmail there is of course the posibility to upload. consider how the thing

    or else , : either. I can afford to encode the file handle as quoted above

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://832835]
help
Chatterbox?
[Rabbi Bob]: Doesn't eat them, just snaps, kills, drops and moves on.
[thezip]: Efficient, that one.
[erix]: my dog could do the classic mouse jump (never caught a mouse :)
[erix]: he caught a hare once (must have been a young one...)
virtualsue uses arcane git commands to resurrect a file, gets it back into shape and quits for the day
[GotToBTru]: a few years ago, when we had 3 dogs, the largest of them caught a chipmunk, but did not know what to do with it other than hold it in his mouth
[GotToBTru]: my wife told him to spit it out, so he did
[erix]: yeah, modern dogs are cute tjhat way :)
[erix]: except of course, the RHODESIAN LION HOUND ! :)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (15)
As of 2017-11-17 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (272 votes). Check out past polls.

    Notices?