@@ -313,14 +313,15 @@ sub output {
313313 $$self {ENCODING } = $encoding ;
314314 }
315315 }
316- if ($encoding ) {
316+ if ($encoding && $encoding ne ' none ' ) {
317317 my $check = sub {
318318 my ($char ) = @_ ;
319319 my $display = ' "\x{' . hex ($char ) . ' }"' ;
320320 my $error = " $display does not map to $$self {ENCODING}" ;
321321 $self -> whine ($self -> line_count(), $error );
322322 return Encode::encode ($$self {ENCODING }, chr ($char ));
323323 };
324+ print (" ENCODING IN $encoding \n " );
324325 print { $$self {output_fh } } encode ($encoding , $text , $check );
325326 } else {
326327 print { $$self {output_fh } } $text ;
@@ -921,25 +922,32 @@ with the POD rendered and the code left intact.
921922
922923=item encoding
923924
924- [5.00] Specifies the encoding of the output. The value must be an encoding
925- recognized by the L<Encode> module (see L<Encode::Supported> ). If the output
926- contains characters that cannot be represented in this encoding, that is an
927- error that will be reported as configured by the C<errors > option. If error
928- handling is other than C<die > , the unrepresentable character will be replaced
929- with the Encode substitution character (normally C<? > ).
925+ [6.1.0] Specifies the encoding of the output. The value must be an encoding
926+ recognized by the L<Encode> module (see L<Encode::Supported> ) or the special
927+ value C<none > . If the output contains characters that cannot be represented in
928+ this encoding, that is an error that will be reported as configured by the
929+ C<errors > option. If error handling is other than C<die > , the unrepresentable
930+ character will be replaced with the Encode substitution character (normally
931+ C<? > ).
930932
931933If the output file handle has a PerlIO encoding layer set, this parameter will
932- be ignored and no encoding will be done by Pod::Man. It will instead rely on
934+ be ignored and no encoding will be done by Pod::Man. It will instead rely on
933935the encoding layer to make whatever output encoding transformations are
934936desired.
935937
938+ As a special case, if the encoding is set to C<none > , no encoding will be done
939+ and characters will be output in Perl's internal representation. This option
940+ only makes sense in combination with output_string(). It is intended for
941+ special cases when the results of formatting are kept in memory and will be
942+ encoded for output at some later step.
943+
936944WARNING: The input encoding of the POD source is independent from the output
937945encoding, and setting this option does not affect the interpretation of the
938- POD input. Unless your POD source is US-ASCII, its encoding should be
939- declared with the C<=encoding > command in the source, as near to the top of
940- the file as possible. If this is not done, Pod::Simple will will attempt to
941- guess the encoding and may be successful if it's Latin-1 or UTF-8, but it will
942- produce warnings. See L<perlpod(1)> for more information.
946+ POD input. Unless your POD source is US-ASCII, its encoding should be declared
947+ with the C<=encoding > command in the source, as near to the top of the file as
948+ possible. If this is not done, Pod::Simple will will attempt to guess the
949+ encoding and may be successful if it's Latin-1 or UTF-8, but it will produce
950+ warnings. See L<perlpod(1)> for more information.
943951
944952=item errors
945953
@@ -1078,7 +1086,7 @@ to the scalar variable pointed to by REF, rather than C<STDOUT>. For example:
10781086 $man->parse_file('/some/input/file');
10791087
10801088Be aware that the output in that variable will already be encoded (see
1081- L</Encoding> ).
1089+ L</Encoding> ) unless the C< encoding > option to Pod::Text is set to C< none > .
10821090
10831091=item parse_file(PATH)
10841092
@@ -1211,6 +1219,8 @@ encoding changes. The L<Encode> module is now used for all output encoding
12111219rather than PerlIO layers, which fixes earlier problems with output to
12121220scalars.
12131221
1222+ Pod::Text 6.1.0 added support for the C<none > option to C<encoding > .
1223+
12141224=head1 CAVEATS
12151225
12161226Line wrapping is done only at ASCII spaces and tabs, rather than using a
@@ -1226,8 +1236,8 @@ Pod::Simple.
12261236
12271237=head1 COPYRIGHT AND LICENSE
12281238
1229- Copyright 1999-2002, 2004, 2006, 2008-2009, 2012-2016, 2018-2019, 2022 Russ
1230- 1239+ Copyright 1999-2002, 2004, 2006, 2008-2009, 2012-2016, 2018-2019, 2022,
1240+ 2024-2025 Russ Allbery <[email protected] >12311241
12321242This program is free software; you may redistribute it and/or modify it
12331243under the same terms as Perl itself.
0 commit comments