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

38 ビュー (過去 30 日間)
sinh
sinh 2015 年 12 月 29 日
コメント済み: Kin Sung Chan 2022 年 12 月 13 日
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 件のコメント
Christine Tobler
Christine Tobler 2015 年 12 月 31 日
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.
sinh
sinh 2016 年 1 月 1 日
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!

サインインしてコメントする。

回答 (3 件)

Jan
Jan 2016 年 1 月 1 日
編集済み: Jan 2016 年 1 月 1 日
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">
  7 件のコメント
Shaul Shvimmer
Shaul Shvimmer 2020 年 7 月 31 日
編集済み: Walter Roberson 2020 年 8 月 6 日
This is everything that appear in my lcdata.xml file, using MATLAB 2020a in Windows 10, and still I'm getting the error message below when trying to use Hebrew in the matlab's editor, for using Hebrew in GUI.
How can this be solved ?
Thank you.
<?xml version="1.0" encoding="UTF-8" ?>
<!-- MathWorks Locale Database -->
<!-- File Name: lcdata.xml -->
<!-- Copyright 2007-2016 The MathWorks, Inc. -->
<lcdata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="lcdata.xsd">
<!-- Note: -->
<!-- This locale database is used to customize the MathWorks locale database. -->
<!-- Codeset entry example -->
<!-- <codeset> -->
<!-- <encoding name="StandardEncodingName" jvm_encoding="JavaEncodingName"> -->
<!-- <encoding_alias name="AliasName"/> -->
<!-- </encoding> -->
<!-- </codeset> -->
<!-- Locale entries example -->
<!-- <locale name="StandardLocaleName" encoding="EncodingName" xpg_name="XpgLocaleName"> -->
<!-- <alias name="AliasName"/> -->
<!-- "region_alias" is only for Mac -->
<!-- <region_alias name="RegionAliasName"/> -->
<!-- </locale> -->
</lcdata>
Walter Roberson
Walter Roberson 2020 年 8 月 6 日
Shaul: Would it be possible for to attach a sample file that is giving this windows-1255 problem?

サインインしてコメントする。


YANG LI
YANG LI 2017 年 10 月 30 日
Same problem with lcdata.xml!!

Kin Sung Chan
Kin Sung Chan 2022 年 12 月 13 日
Well, I use VSCode to open the Matlab .m file, and resave with GBK encoding. (bottom right button of the VSCode interface next to Spaces) (Well, I try with different types of encoding, and only this one works)
After that, Matlab can display the Chinese characters with no issues.

カテゴリ

Help Center および File ExchangeInstall Products についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by