I have a text file test.txt
with the UTF8 encoded content äöü
(these are German umlauts and just an example, the file size is 6 Bytes). I also have a Cygwin terminal on a Windows 10 PC with the correct LANG settings:
$ cat test.txt
äöü
I'd like to print the content of this file with a Perl script, but can't get it to work.
open my $fh, '<', 'test.txt';
print <$fh>;
close $fh;
results in
$ perl test.pl
├ñ├Â├╝
I tried all variations I found at How can I output UTF-8 from Perl? - none of them solved my problem. What's wrong?
EDIT per request:
$ file test.txt
test.txt: UTF-8 Unicode text, with no line terminators
$ echo $LANG
I also tried setting LANG to de_DE.UTF-8
.
EDIT to narrow down the problem: If I try this with the Perl version 5.32.1 included in Cygwin, it works as expected. It still doesn't work in Strawberry Perl version 5.32.1. So it's probably no Perl problem nor a Windows problem nor something with language or encoding settings, it's a Strawberry Perl problem.