# Importing file as a string causes a puzzle

I generate simple txt file and import it as follows: a = Import["binary.txt"]; b = Import["binary.txt", "String"]. It appears then that lengths of imported strings a and b are quite different. But why?

• that's how i generate the txt file, just in case: Export["binary.txt", ExportString[RandomReal[1000, 10], "Binary", "DataFormat" -> "Real32"]] – funnyp0ny Oct 31 '14 at 18:42

Import["binary.txt"]


in this case is equivalent to

Import["binary.txt", "Text"]


not to

Import["binary.txt", "String"]


Documentation states that Import["binary.txt"] "reads a text file, taking the character encoding to be "UTF8" by default." Whereas for format "String" documentation states that "imports a raw sequence of bytes and returns them as a Wolfram Language character string."

• Thanks! Encoding really was the point, Import["binary.txt", CharacterEncoding -> "ASCII"] gives the same as "string". – funnyp0ny Oct 31 '14 at 21:32