Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
add comment

1 Answer

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:

StringReplace[
 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
1  
@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
add comment

Your Answer

 
discard

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.