I need to make shure that the output file i create with my perl script has the codeset cp1252 and not UTF-8 because it will be used within a UNIX SQLplus framework which handles german "umlauts" not correctly when it insert that values into the database columns (I use strawberry perl v5.18 within Windows 10 and i cannot set NLS_LANG or chcp within the UNIX SQL environment).
With this little test script i can reproduce that the output file "testfile1.txt" is allways in UTF-8 but "testfile2.txt" is CP1252 as expected. How can i force the output for "testfile1.txt" to be also CP1252 even if there are no "special" chars within the text ?
#!/usr/bin/env perl -w
use strict;
use Encode;
# the result file under Windows 10 will have UTF-8 codeset
open(OUT,'> testfile1.txt');
binmode(OUT,"encoding(cp-1252)");
print OUT encode('cp-1252',"this is a test");
close(OUT);
# the result file under Windows 10 will have Windows-cp1252 codeset
open(OUT,'> testfile2.txt');
binmode(OUT,"encoding(cp-1252)");
print OUT encode('cp-1252',"this is a test with german umlauts <ÄäÜüÖöß>");
close(OUT);