in reply to Remove ÿþ from a string

G'day AnishaM,

TMTOWTDI:

$ perl -Mutf8 -E 'say join "", split /ÿþ/, q{AÿþBÿþÿþC}' ABC

See also: Benchmark.

— Ken

Replies are listed 'Best First'.
Re^2: Remove ÿþ from a string
by perl-diddler (Chaplain) on Sep 17, 2016 at 18:56 UTC
    This is an example from some code I wrote to read in a MS file that had a superfluous BOM.
    my @file; { my $lh; open($lh, "<:utf8:crlf", $LogFn) || do { Pe "\nlogfile <%s> not found", $LogFn; help; }; @file = grep { s/([^\r]+)$/$1/; m{^\s*$} ? undef : $_; } <$lh>; close $lh; } $file[0] =~ s/^\N{U+FEFF}//; # UTF-8 BOM
    The stuff immediately after the open was to remove the carriage returns, so I could have normal unix line endings.

    "Pe", BTW is part of "P". From what I understand, in newer perls, a new keyword, "err" is weaker version of the same (doesn't allow a format statement).

    Hope this is of use.