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

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

This script…

#!perl use strict; use warnings; use open qw( :encoding(UTF-8) :std ); use Text::CSV_XS; my $csv = Text::CSV_XS->new({ always_quote => 1, binary => 1, eol => $/, }); while (my $fields = $csv->getline(*ARGV)) { $csv->print(\*STDOUT, $fields); } $csv->eof() or $csv->error_diag(); exit 0;

…produces this output…

"BLACK SPADE SUIT","BLACK HEART SUIT","BLACK DIAMOND SUIT","BLACK CLUB SUIT"
"™","™","™","™"

…from this UTF-8 input…

"BLACK SPADE SUIT","BLACK HEART SUIT","BLACK DIAMOND SUIT","BLACK CLUB SUIT"
"♠","♥","♦","♣"

Why?

If I remove the use open statement, the output is identical to the input. This is exactly the reverse of the behavior I expect.

I'm using Strawberry Perl 5.12 for Windows and Text::CSV_XS version 0.85.

(I don't know the answer to the question I'm asking despite having dutifully read all the relevant documentation. Just pointing me toward a perldoc page won't help me. Thanks.)


In reply to Why Doesn't Text::CSV_XS Print Valid UTF-8 Text When Used With the open Pragma? by Jim

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (8)
    As of 2015-07-06 11:41 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (73 votes), past polls