3 ms·
If you don't allow non-ascii then you may have to mangle some people's names in the copyright header. It's good to check files for unexpected characters, thoug
by bloak 7y ago
If you don't allow non-ascii then you may have to mangle some people's names in the copyright header.
It's good to check files for unexpected characters, though. Here's some Perl to do it:
perl -e 'binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8");
foreach (split(//, join("", <STDIN>))) { ++$c{$_}; }
foreach (sort(keys %c)) { printf "%8d %s\n", $c{$_}, $_; }'
I tested that on a text file I was working on ... and I discovered that the file contained a BOM (U+FEFF), not at the start of the file, but at a random point in the middle of the file. I've deleted it. Who knows what problems it might have caused for me later?
You could have a pre-commit git hook that refers to a whitelist of allowed non-ascii characters, or also allow all alphabetic characters, or something like that.