diff options
author | B. Watson <urchlay@slackware.uk> | 2025-02-03 03:18:25 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2025-02-03 03:18:25 -0500 |
commit | 489370d1500383f3b2760a50637f11a817870004 (patch) | |
tree | 4e97ad3ba82e13206aa75ff20334b9fe0e6cb464 | |
parent | 3a87634357407be554f32880d9a6600d2db55431 (diff) | |
download | misc-scripts-489370d1500383f3b2760a50637f11a817870004.tar.gz |
bsgrep: use utf-8 when in utf-8 locale.
-rwxr-xr-x | bsgrep | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -73,6 +73,15 @@ sub handle_line { } ### main() +# TODO: do we need 'use locale'? +# also, why does reading iso-8859-1 text auto-convert to utf-8? +for (qw/LANG LC_CTYPE LC_ALL/) { + if(($ENV{$_} // "") =~ /utf-?8/i) { + binmode(\*STDIN, ':utf8'); + binmode(\*STDOUT, ':utf8'); + last; + } +} if(defined($ARGV[0])) { if($ARGV[0] =~ /-help/) { |