unicode characters in .m file
Ältere Kommentare anzeigen
Matlab claims to be Unicode compliant, but only characters whose code # is ≤255 can be saved in .m files. I can accept that Matlab code words must be in ASCII, but there should be no such constraints on characters in comments or text strings. It would be nice if useful characters, like "≈", "Ω", "≤","≥", etc., could be saved in comments. On a similar note, while a character whose code is ≥128 and ≤255 can be stored in .m files, it is not possible to include them directly in graphics labels or text; typing '\circ' (1970s LaTex convention) seems clunky compared to "Alt+0176" (or pasted from another document) for the degrees symbol(°).
2 Kommentare
Paul McKenzie
am 19 Jul. 2017
Walter Roberson
am 19 Jul. 2017
unicode characters can be included directly for text() objects when using Interpreter Tex (the default) or Interpreter None . However, at this time unicode characters cannot be included directly for latex.
Akzeptierte Antwort
Weitere Antworten (5)
MathWorks Support Team
am 19 Feb. 2021
Bearbeitet: MathWorks Support Team
am 19 Feb. 2021
2 Stimmen
As of R2020a, the MATLAB Editor supports UTF-8 characters, and uses UTF-8 as the default encoding for new plain text files, including MATLAB code files with a .m extension.
Walter Roberson
am 19 Mai 2017
1 Stimme
The instructions for OS-X (Mac) are given at in the Release Notes https://www.mathworks.com/help/matlab/release-notes.html?rntext=internationalization&startrelease=R2012a&endrelease=R2017a&groupby=release&sortby=descending&searchHighlight=internationalization
1 Kommentar
Stephane
am 9 Nov. 2018
This one worked for me (MacOS Mojave, R2018b) - Thanks !
Jan
am 19 Mai 2017
0 Stimmen
Please read https://www.mathworks.com/matlabcentral/answers/262114-why-i-can-not-read-comments-in-chinese-in-my-mfile . It is possible to display Unicode in the editor.
14 Kommentare
Paul McKenzie
am 23 Mai 2017
Paul McKenzie
am 23 Mai 2017
The answer from Jinghao Lei https://cn.mathworks.com/matlabcentral/answers/280988-how-do-i-get-my-matlab-editor-to-read-utf-8-characters-utf-8-characters-in-blank-squares-in-editors does work on MATLAB R2017a, just rename the lcdata_utf8.xml to lcdata.xml first.
Paul McKenzie
am 15 Jan. 2018
Paul McKenzie
am 10 Mai 2018
Walter Roberson
am 10 Mai 2018
Paul McKenzie: did you happen to do Windows Creator Spring Update within the last week?
Paul McKenzie
am 11 Mai 2018
Bearbeitet: Paul McKenzie
am 11 Mai 2018
Duijnhouwer
am 31 Aug. 2018
Bearbeitet: Walter Roberson
am 31 Aug. 2018
explanation in https://www.mathworks.com/matlabcentral/answers/262114-why-i-can-not-read-comments-in-chinese-in-my-mfile . does not apply to 2018a.
Paul McKenzie
am 12 Sep. 2018
Walter Roberson
am 12 Sep. 2018
Mathworks needs to do more to make it easy to use Unicode in source code, UTF-8 at least.
Paul McKenzie
am 30 Apr. 2019
Bearbeitet: Paul McKenzie
am 1 Mai 2019
Paul McKenzie
am 14 Sep. 2019
Paul McKenzie
am 3 Apr. 2020
Shaul Shvimmer
am 31 Jul. 2020
I'm using MATLAB 2020a and I still have the problem - I cannot change encoding to UTF-8 using Windows 10.
Muhammad Kashif
am 14 Mär. 2018
Bearbeitet: Muhammad Kashif
am 6 Apr. 2018
0 Stimmen
Assalam O Alikum and good day all
For those using languages having Arabic script e.g. Arabic ,Urdu.
1)Change the system Locale to Urdu(Pakistan) for Urdu.For Arabic, change the system locale accordingly.
2)For displaying Urdu and Arabic in Matlab Command prompt,use the following command:
>>slCharacterEncoding('UTF-8')
3) In the matlab editor, to make the string functions like strsplit() work properly for Urdu and Arabic, this should be the first line of code:
feature('DefaultCharacterSet', 'UTF8');
Best regards
1 Kommentar
Walter Roberson
am 14 Sep. 2019
Unfortunately, slCharacterEncoding() is for Simulink use, not the MATLAB command prompt.
Jean-Michel Rousseau
am 10 Jan. 2020
0 Stimmen
Hello,
Is ther any way to definitively change the 'DefaultCharacterSet' without the need to use the feature function at every start of Matlab?
I need to use 'windows-1252' and Matlab (& Simulink) always start with "UTF-8". It as recently canged after updating to the R2019b. As I can't solve the problem into R2019b (my folders and files with accent can't be used anymore without renaming them), i go back to a fresh R2016b but the problem remain :-(
Kategorien
Mehr zu App Building finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!