In order to handle UTF strings properly, you have to read them from your text file using a binary approach, as follows:
fid = fopen('mytext.txt','rb');
bytes = fread(fid,'*uint8')';
fclose(fid);
txt = native2unicode(bytes,'UTF-8');
At this point, your string will contain the correct values, but Matlab will still be unable to show it properly. To fix this problem, you either have to use the Java Swing
underlying labels with a font that supports unicode characters:
import('java.awt.*');
import('java.swing.*');
lbl = JLabel();
lbl.setFont(Font('Arial Unicode MS',Font.PLAIN,30));
lbl.setText(txt);
or the undocumented function that modifies the default character set used by Matlab (which is, by default, set to ISO-8859-1
):
feature('DefaultCharacterSet','UTF-8');