in reply to Unicode in one-liner

If you are on a system with a UTF8 locale (e.g. my default installation of Ubuntu), when you pass the -C flag to the interpreter, "the standard I/O handles and the default open() layer are UTF-8-fied" (you can specify encoding via an argument to -C if you need to; check with locale -a).

perl -nC -E 'print "\N{U+2022} $_"' /usr/share/dict/words
... • zooms • zoos • zucchini • zucchini's • zucchinis • zwieback • zwieback's • zygote • zygote's • zygotes • Ångström • éclair • éclair's • éclairs • éclat • éclat's • élan • élan's • émigré • émigré's • émigrés • épée • épée's • épées • étude • étude's • études

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Unicode in one-liner
by morgon (Priest) on Dec 27, 2016 at 00:46 UTC
    Great, I knew there was a nicer way.

    Unfortunately there does not seem to be a way to combine all the flags (the way you can combine "n" and "e" or "E"), so one has to live with two flag-groups.

    As the "ne"-combination is something I am already used to, I am going to use

    perl -C -ne '...'
    Many thanks!

      Unfortunately switches

      :D

      I never use switches ;)

      perllanse " print join q{,}, map { qq{\x22$_\x22} } @F " perllansE " say join q{,}, map { qq{\x22$_\x22} } @F " perllCSDanse " print join q{,}, map { qq{\x22$_\x22} } @F " perllCSDansE " say join q{,}, map { qq{\x22$_\x22} } @F "

        Doesn’t work for me:

        13:18 >perllanse "print 'Hi!';" 'perllanse' is not recognized as an internal or external command, operable program or batch file. 13:19 >perl -v This is perl 5, version 24, subversion 0 (v5.24.0) built for MSWin32-x +64-multi-thread-ld ...

        Are you using some form of aliasing scheme?

        Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

        I never use switches either.

        I use flags.

        Don't quote what has not been said...

Re^2: Unicode in one-liner
by shawnhcorey (Friar) on Dec 29, 2016 at 13:06 UTC

    I like using names where possible.

    perl -nC -E 'print "\N{BULLET} $_"' /usr/share/dict/words

      Hi shawnhcorey,

      perl -nC -E 'print "\N{BULLET} $_"' /usr/share/dict/words

      Note that the automatic loading of charnames was added in v5.16. For older versions of Perl, there's either 1nickt's one-liner, or:

      perl -Mcharnames=:full -nC -E 'print "\N{BULLET} $_"' /usr/share/dict/ +words

      Regards,
      -- Hauke D