in reply to Re^2: Unexpected interaction between decode_entities() and lc()
in thread Unexpected interaction between decode_entities() and lc()
First, I would strongly recommend against using any of the functions from the utf8 module, since these are really only meant for use if one knows the inner workings of how Perl handles Unicode and non-Unicode strings. Second, it seems binmodeing STDIN is not enough - instead, try the open pragma with the :std option <update> since that also sets the default open modes and works on files passed on the command line as well </update>. The following works for me, both for a UTF-8 file piped into perl and a file listed on the command line:
use warnings; use strict; use open qw/:std :utf8/; use HTML::Entities; while(<>) { chomp; print lc(decode_entities($_)), "\n"; }
Update: Added a missing "not", oops :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Unexpected interaction between decode_entities() and lc()
by ikegami (Patriarch) on Nov 16, 2017 at 19:00 UTC | |
by haukex (Archbishop) on Nov 16, 2017 at 19:46 UTC |