I am writing a script that inserts a UTF-16 encoded text file as input and outputs a UTF-16 encoded text file.
use open "encoding(UTF-16)"; open INPUT, "< input.txt" or die "cannot open > input.txt: $!\n"; open(OUTPUT,"> output.txt"); while(<INPUT>) { print OUTPUT "$_\n" }
Say my program writes everything from input.txt to the file output.txt.
This WORKS works fine in my cygwin environment, which uses "This is perl 5, version 14, subversion 2 (v5.14.2), created for cygwin-thread-multi-64int"
But in my Windows environment that uses "This is perl 5, version 12, subversion 3 (v5.12.3), created for MSWin32-x64-multi-thread",
Each line in the output.txt file is preliminarily delayed by crazy characters except the first line.
For instance:
<FIRST LINE OF TEXT> ΰ¨ γ γβ° γβ° εζ γ δζ ζ€ζ δβΈβΈβΈ εηζζΈζ δ ξΰ΄<SECOND LINE OF TEXT> ...
Can anyone make it clear why it works on cygwin but not windows?
EDIT: after printing the encoded layers as suggested.
In Windows environment:
unix crlf encoding(UTF-16) utf8 unix crlf encoding(UTF-16) utf8
In a Cygwin environment:
unix perlio encoding(UTF-16) utf8 unix perlio encoding(UTF-16) utf8
The only difference between the perlio and crlf layer.
source share