I wrote this in 1986. It was posted many times to Usenet and appears in many packages. This is the original one from INN 1.4
If you need a version that handles UTF-8 Unicode, you can find it in the INN release.
My code is in the public domain, it's old enough to have outgrown any copyright.