Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to import a text file with UCS-2 Little Endian codification but I can't read it correctly. There's any hidden option to read this files ??

I'd tried with Import (using ByteOrdering option) and ReadList.

And example file can be find here

Thanks !!

share|improve this question
up vote 3 down vote accepted

I suspect that you want the result of using CharacterEncoding -> "Unicode":

Import["msscript.scp", "Text", CharacterEncoding -> "Unicode"]

and possibly also replacing the carriage return / newline pair with newline:

 Import["msscript.scp", "Text", CharacterEncoding -> "Unicode"],
 "\r\n" -> "\n"
share|improve this answer
In fact, as I'm interested in the lines to analyze the content, for my works better this: StringReplace[#, "\r" -> ""] & /@ Import["msscript.scp", {"Text", "Lines"}, CharacterEncoding -> "Unicode"]; – SMiranda Aug 9 '12 at 13:09
@SMiranda okay, I'm glad this helped. For what it's worth StringReplace can operate on a list of strings so the output from this should be the same as what you wrote: StringReplace[ Import["msscript.scp", {"Text", "Lines"}, CharacterEncoding -> "Unicode"], "\r" -> "" ] – Mr.Wizard Aug 9 '12 at 13:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.