MATLAB Answers

sinh
0

Why I can not read comments in Chinese in my Mfile?

Asked by sinh
on 29 Dec 2015
Latest activity Answered by YANG LI
on 30 Oct 2017
In the past, I wrote a Mfile with very much comments in Chinese (after character %) in my PC with Windows7(x64) and Matlab 2013b. Last month, I have setup my PC with Windows10 and Matlab2015b but now although I can open this Mfile but I can not read those Chinese comments. Those Chinese comments's characters is not Chinese characters. Now I also have many Chinese fonts (include Chinese font I have used to write this Mfile) in my Windows/Fonts. Please let me know how I have to do to read those importan comments in my Mfile! Thank you very much!

  2 Comments

That sounds very annoying. Can you attach a small example of such a file to this post? I have some different operating systems and MATLAB versions available, and could try where the problem comes from.
Christine Tobler! Thank you very much for your repply! Attach is a small Mfile of me. Now my laptop have two x64 operating systems Windows10 and Windows7 setup in C: and D: driver, but in both of two ooperating systems, Matlab can not read the comments in Chinese characters. In Matlab I also have setup Chinese in Preference/Fonts but I still could not read comment in Chinese. I think it is not easy to solve and I have spend lots of time but now I still could not solve it. I hope you try it and can give me a help. See you!

Sign in to comment.

2 Answers

Answer by Jan
on 1 Jan 2016
Edited by Jan
on 1 Jan 2016

The Chinese characters appear directly, when I open the M-file with Notepad++, althought I did not install any Chinese fonts and run an English version of the OS (Win7 64). When I open the File in Matlab R2009a, R2011b and 2015b, the pure ASCII characters are shown.
You can try this - I'm not sure if this works reliably on all operating systems:
  • At first check your locale value:
feature('locale')
  • Then open the locale data XML file:
edit(fullfile(matlabroot, '/bin/lcdata.xml'))
  • Replace (in my case):
<locale name="en_US" encoding="ISO-8859-1" xpg_name="en_US.ISO8859-1">
by
<locale name="en_US" encoding="UTF-8" xpg_name="en_US.UTF-8">

  5 Comments

I'm running R2017a. When I go to edit 'lcdata.xml', there is no mention of any ISO-8859-1 encoding or UTF-8, except for the first line: version="1.0" encoding="UTF-8" ? I don't know what the question marks just inside the ends of that line mean. Is the encoding specification in a different place now?

As Paul said in R2017a edition, there's just a couple line in it and can't find

name="en_US" encoding="ISO-8859-1" xpg_name="en_US.ISO8859-1"

As Paul and Dodo said, nothing like [name="en_US" encoding="ISO-8859-1" xpg_name="en_US.ISO8859-1" ] can be found. In R2017b editoin.

Sign in to comment.


Answer by YANG LI
on 30 Oct 2017

Same problem with lcdata.xml!!

  0 Comments

Sign in to comment.