Why don't you fix the bad files instead of having your program handle them?
...mostly because I'd rather avoid having to get down to the encoding nitty-gritties, if there is some 'proper' way of doing it with Perl's built-in encoding support. For example, the ad-hoc approach you've shown would also replace valid surrogate pairs, which I'd rather keep, if possible (just in case). Sure, the regex could presumably be fixed to handle this (using lookahead), but this would be kind of reinventing the wheel... OTOH, it looks like the best workaround for the issue so far — So, thanks!
In reply to Re^2: Handling malformed UTF-16 data with PerlIO layer
by almut
in thread Handling malformed UTF-16 data with PerlIO layer
by almut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |