Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: App::Cmd::Command and abstract encoding (=encoding utf8)

by Anonymous Monk
on Feb 28, 2013 at 15:55 UTC ( #1021073=note: print w/replies, xml ) Need Help??

in reply to App::Cmd::Command and abstract encoding

perlpod/perlpodspec says use pod  =encoding encodingname directive, and Pod::Weaver should respect that, even though =encoding doesn't appear in the test suite

Replies are listed 'Best First'.
Re^2: App::Cmd::Command and abstract encoding (=encoding utf8 or BOM)
by Anonymous Monk on Feb 28, 2013 at 16:03 UTC
Re^2: App::Cmd::Command and abstract encoding (=encoding utf8)
by McA (Priest) on Feb 28, 2013 at 16:14 UTC


    you're completely right. I do use =encoding and I get the right output of perldoc MyPackage. But the method abstract of App::Cmd::Command doesn't respect it when scanning for an abstract message for showing as help text. That's why I wrote earlier that this method could scan for a pod line =encoding and try to respect the given encoding. Have a look at the source code.

    Best regards

      I asked rjbs on IRC and he said his preferred route was to just interpret all abstracts extracted from the source as being UTF-8, and forget about scanning for the encoding.

      I've offered to provide him with a patch, but if anyone beats me to it, that's just fine by me.

      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

        I'm not really happy with that "solution", because if a perl source is not declared beeing utf8-encoded it is latin1-encoded by default. A German umlaut in an ABSTRACT would be decoded wrong.

        My proposal from above:

        --- App/Cmd/ 2013-01-31 01:37:50.000000000 +0100 +++ App/Cmd/ 2013-03-04 14:57:08.398638804 +0100 @@ -11,6 +11,7 @@ # ABSTRACT: a base class for App::Cmd commands use Carp (); +use Encode (); sub prepare { @@ -115,6 +116,7 @@ local $/ = "\n"; my $inpod; + my $enc_seen; while (local $_ = <$fh>) { # =cut toggles, it doesn't end :-/ @@ -127,10 +129,10 @@ next unless $inpod; chomp; - + $enc_seen = $1 if(/^=encoding\s+(\S+)/); next unless /^(?:$class\s-\s)(.*)/; - $result = $1; + $result = $enc_seen ? Encode::decode($enc_seen, $1) : $1; last; }

        Best regards

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1021073]
[hippo]: See also Getting Started with Perl for some gentle introductory tutorials.
[thao4]: I don't see where I can post my question. I am french so not good in English
[erix]: go to the bottom of this page: Seekers of Perl Wisdom

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2018-02-21 09:57 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (276 votes). Check out past polls.