I'm using Windows ActivePerl and I can never seem to get conversion of a UCS2 little endian file to convert properly to utf-8. Best i could muster is what seems a proper conversion except that the first line which is 4 characters is mangled in strange chinese/japanese characters but the rest of file seems ok.
What I really want is to do oneliner /search/replace perl regex of the usual:
perl -pi.bak -e 's/replacethis/withthat/g;' my_ucs2file.txt
That won't work so I tried to first see if perl can do proper conversion and I'm stuck, i'm using:
perl -i.BAKS -MEncode -p -e "Encode::from_to($_, 'UCS-2', 'UTF-8')" My_UCS2file.txt
I tried using UCS2
or UCS-2LE
but still can't get a proper conversion.
I recall somewhere someone had to delete a couple bits or something at the beginning of a UCS2
file to get conversion working but I can't remember...
When I tried PowerShell it complained it didn't know UCS2
/ UCS-2
...??
Appreciate any ideas. I noticed NotePad++ does open it and recognize it fine and I can edit and resave in notepad but there's no commandline ability...