Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Outside data sources are tricky in Perl. For command-line arguments, you're probably getting them as the encoding specified in your locale. Don't rely on your locale to be the same as someone else who might run your program.</p> <p>You have to find out what that is then convert to Perl's internal format. Fortunately, it's not that hard.</p> <p>The <a href="http://search.cpan.org/dist/I18N::Langinfo" rel="noreferrer">I18N::Langinfo</a> module has the stuff you need to get the encoding:</p> <pre><code> use I18N::Langinfo qw(langinfo CODESET); my $codeset = langinfo(CODESET); </code></pre> <p>Once you know the encoding, you can decode them to Perl strings:</p> <pre><code> use Encode qw(decode); @ARGV = map { decode $codeset, $_ } @ARGV; </code></pre> <p>Although Perl encodes internal strings as UTF-8, you shouldn't ever think or know about that. You just decode whatever you get, which turns it into Perl's internal representation for you. Trust that Perl will handle everything else. When you need to store the data, ensure that you use the encoding you like.</p> <p>If you know that your setup is UTF-8 and the terminal will give you the command-line arguments as UTF-8, you can use the <code>A</code> option with Perl's <code>-C</code> switch. This tells your program to assume the arguments are encoded as UTF-8:</p> <pre><code>% perl -CA program </code></pre> <p>You also get that with just <code>-C</code>, which turns on several other Unicode options:</p> <pre><code>% perl -C program </code></pre> <p>I find "if you know" to be a big red flag that really means "we're not sure", however.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload