matlabunicode

MATLAB using unicode characters in MATLAB GUI


I want to use Tamil word (Tamil is an Indian language) in list box of MATLAB guide instead of default English word. How to do that?


Solution

  • I believe MATLAB listboxes can't display Unicode. However, you can display Unicode by using a Java listbox in your GUI instead:

    f = figure;
    txt = char(hex2dec('0B85'),hex2dec('0B86'),hex2dec('0B87'));
    b = javax.swing.JList({'hello','hello2',txt});
    c = javacomponent(b,[20,20,500,100],f);
    fn = java.awt.Font('Arial Unicode MS',0,10);
    set(b,'font',fn)
    

    The variable txt contains some Tamil characters found from the Wikipedia page on Unicode - my apologies if it says anything rude :)

    The command javacomponent is undocumented and may change from release to release, so don't rely on it if your application is important. You'll need a Unicode font as well - I've used Arial Unicode MS, but if you're not on Windows you'll need a different one.

    Lastly, if you're using javacomponent, I'd recommend that you move away from GUIDE for developing your GUI - it will become difficult to manage.