I'm using Mathematica v10.0.2 on Win7.

I have a text file in which there are some Chinese characters and I would Import the file into Mathematica as a string by:


However, the Chinese characters were all "translated" to strange characters like "Ò»Êø¹â".

Note that a string containing Chinese characters can be correctly Export ed to a txt file.

nothing changes when I try $CharacterEncoding = "UTF-8" or $SystemCharacterEncoding = "UTF-8"

what should I do?

Or is there any I can turn the "Ò»Êø¹â" back to the characters in original txt file?

  • 1
    $\begingroup$ maybe you can use option CharacterEncoding -> "CP936" $\endgroup$ – partida Apr 8 '16 at 7:41

refering to Can I read Chinese characters with ReadList correctly? here is the solution:

first try

ReadList["...file.txt", Record, 1]], #] & /@ $CharacterEncodings

read the output then select the one of $CharacterEncodings which correctly translated the characters (which may depend on your systems or Mathematica versions), inset it into the # in the code above.

for my Mma10.0.2 on Win7, It's "CP936" that works

ReadList["...file.txt", Record, 1]], "CP936"] & /@ $CharacterEncodings

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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