in reply to Encoding question
I've tried using the "Encode" module to re-code this to UTF-8, or even ASCII but nothing I do can make this work.
The previous replies have given enough info to read the file correctly. If you want to write the data to a new file using utf8 instead of utf-16le, you'd want to make sure to set the output file handle to utf8 mode, and replace the "utf-16" in the opening xml tag with "utf-8":
open(IN,"<:encoding(utf-16le)","your_file.xml"); { local $/; $_ = <IN>; } s/(xml version="1.0" encoding="utf)-16/$1-8/; # (that was cheating, but what the heck) # do whatever else needs to be done with the data # -- but use a real xml parser for that... then: binmode STDOUT, ":utf8"; # or whatever file handle you need to use print;
|
|---|