BillKSmith has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; open(my $in, "<:encoding(UTF-16)", "INPUT.TXT" ) || die("Error open INPUT.TXT\n"); my $first_line = <$in>; my $length_of_line = length $first_line; my $second_last_character = substr $first_line, -2; print $first_line; print $length_of_line, ' ', ord($second_last_character), "\n"; close $in; OUTPUT: 24.07.2016 18:26:19.171 [>] ☺?;20;0;37;0; 43 13 For reference, here is a hex dump of the first few lines of the file. (reposted with permission) 0000000: fffe 3200 3400 2e00 3000 3700 2e00 3200 ..2.4...0.7...2. 0000010: 3000 3100 3600 2000 3100 3800 3a00 3200 0.1.6. .1.8.:.2. 0000020: 3600 3a00 3100 3900 2e00 3100 3700 3100 6.:.1.9...1.7.1. 0000030: 2000 5b00 3e00 5d00 2000 0100 3f00 3b00 .[.>.]. ...?.;. 0000040: 3200 3000 3b00 3000 3b00 3300 3700 3b00 2.0.;.0.;.3.7.;. 0000050: 3000 3b00 0d00 0a00 0d00 0a00 fffe 3200 0.;...........2.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Windows newlines in unicode
by haukex (Archbishop) on Sep 17, 2016 at 16:21 UTC | |
by BillKSmith (Monsignor) on Sep 17, 2016 at 16:57 UTC | |
by haukex (Archbishop) on Sep 17, 2016 at 17:01 UTC |