Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Using encoding

by Kenosis (Priest)
on Jan 10, 2013 at 18:31 UTC ( #1012715=note: print w/ replies, xml ) Need Help??


in reply to Using encoding

Add binmode $output; right after opening the CSV file for writing. For example:

use strict; use warnings; my $string = ''; open my $output, '>:encoding(utf8)', 'out.txt' or die $!; binmode $output; print $output $string; close $output;

Contents of out.txt:

Contents of out.txt without binmode $output;:

£


Comment on Re: Using encoding
Select or Download Code
Re^2: Using encoding
by vsespb (Hermit) on Jan 11, 2013 at 17:59 UTC
    It's more correct to write:
    use strict; use warnings; use utf8; my $string = ''; open my $output, '>:encoding(utf8)', 'out.txt' or die $!; #binmode $output, ":encoding(utf8)"; print $output $string; close $output;
    (with or without 'binmode $output, ":encoding(utf8)"' but without 'binmode $output;')

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012715]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-10-21 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (95 votes), past polls