Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unicode characters in MATLAB source files

I'd like to use Unicode characters in comments in a MATLAB source file. This seems to work when I write the text; however, if I close the file and reload it, "unusual" characters have been turned into question marks. I guess MATLAB is saving the file as ASCII.

Is there any way to tell MATLAB to use UTF-8 instead?

like image 620
LaC Avatar asked Feb 13 '11 13:02

LaC


People also ask

Does Matlab support Unicode?

MATLAB® stores all characters as Unicode® characters using the UTF-16 encoding, where every character is represented by a numeric code value. (Unicode incorporates the ASCII character set as the first 128 symbols, so ASCII characters have the same numeric codes in Unicode and ASCII.)

How do I show special characters in Matlab?

Display a superscript in the title using the ^ character. The ^ character modifies the character immediately following it. Include multiple characters in the superscript by enclosing them in curly braces {} .

How do I find Unicode characters?

To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X. For more Unicode character codes, see Unicode character code charts by script.

What characters are Unicode?

Unicode covers all the characters for all the writing systems of the world, modern and ancient. It also includes technical symbols, punctuations, and many other characters used in writing text.


2 Answers

According to http://www.mathworks.de/matlabcentral/newsreader/view_thread/238995

feature('DefaultCharacterSet', 'UTF8') 

will change the encoding to UTF-8. You can put the line above in your startup.m file.

like image 163
Gabra Avatar answered Sep 18 '22 17:09

Gabra


How the MATLAB Process Uses Locale Settings shows how to set the encoding for different platforms. Use

feature('DefaultCharacterSet') 

You can read more about this undocumented function here. See also this Matlab Central thread for other options.

like image 45
zellus Avatar answered Sep 22 '22 17:09

zellus