<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
# forcesjis.pl - test the text is pure sjis (not including hankaku katakana)

$BinaryPattern = '\.(BMP|CHM|CUR|DAT|DLL|DOC|EXE|GIF|ICO|JPG|LIB|PNG|WAV)$';

for $arg (@ARGV) {
	if (-d $arg) {
	#	chdir($arg) || warn("cannot chdir to $arg ($!)\n");
		next;
	}
	if ($arg =~ m/$BinaryPattern/i) {
		warn("filename $arg seems to be binary: check skipped\n");
		next;
	}
	open(FILE, $arg) || (warn("cannot open $arg ($!)\n"), next);
	$ARGV = $arg;
	while (&lt;FILE&gt;) {
		for ($i = 0; $i &lt; length($_); $i++) {
			$c = substr($_, $i, 1);
			if ($c =~ /[\t\n\r\x20-\x7E\xA1-\xFE]/) {
				next;
			}
			&amp;barf('Broken EUC', $_);
		}
	}
}
exit 0;

sub barf {
	print STDERR "$ARGV: " if $ARGV ne '-';
	warn @_, ". Only EUC-JP or ASCII allowed.\n";
	exit 1;
}
</pre></body></html>