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?
$\begingroup$
$\endgroup$
1
-
$\begingroup$ that's how i generate the txt file, just in case: Export["binary.txt", ExportString[RandomReal[1000, 10], "Binary", "DataFormat" -> "Real32"]] $\endgroup$– funnyp0nyCommented Oct 31, 2014 at 18:42
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
1
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."
-
$\begingroup$ Thanks! Encoding really was the point, Import["binary.txt", CharacterEncoding -> "ASCII"] gives the same as "string". $\endgroup$ Commented Oct 31, 2014 at 21:32