in reply to Handling malformed UTF-16 data with PerlIO layer
#!/usr/bin/perl # usage: # rem_surrogate.pl < infile > outfile use strict; use warnings; binmode STDIN; # Disable :crlf binmode STDOUT; # Disable :crlf my $read_size = 16*1024; my $buf = ''; for (;;) { my $rv = read(STDIN, $buf, $read_size, length($buf)); die("$!\n") if !defined($rv); last if !$rv; $_ = substr($buf, 0, int(length($buf)/2)*2, ''); s/\G(.)(?:[\xD8-\xDF]|(.))/ defined($2) ? $1.$2 : "\xFD\xFF" /esg; print; } print("\xFD\xFF") if length($buf);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Handling malformed UTF-16 data with PerlIO layer
by almut (Canon) on Oct 27, 2008 at 22:38 UTC | |
by ikegami (Patriarch) on Oct 28, 2008 at 00:24 UTC | |
by almut (Canon) on Oct 28, 2008 at 01:02 UTC | |
by graff (Chancellor) on Oct 28, 2008 at 06:33 UTC | |
by almut (Canon) on Oct 28, 2008 at 20:12 UTC | |
| |
by ikegami (Patriarch) on Oct 28, 2008 at 10:13 UTC | |
by ikegami (Patriarch) on Oct 28, 2008 at 02:34 UTC |