Skip to main content

Raymii.org Raymii.org Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed | Gopher

Strip all non-ascii characters from a file

Published: 27-06-2013 | Author: Remy van Elst | Text only version of this article


❗ This post is over eight years old. It may no longer be up to date. Opinions may have changed.

I'm developing a desktop monitoring app, Leaf Node Monitoring, open source, but paid. For Windows, Linux & Android, go check it out.

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days.

This snippet strips all non-ascii characters from a file. It backs up the original file. This is handy if you have input for programs that bork on non- ascii input like older mainframes and such.

perl -i.bk -pe 's/[^[:ascii:]]//g;' filename
Tags: ascii , perl , snippets , utf-8