MATLAB Answers

Burmese Character as a string

5 views (last 30 days)
v k
v k on 7 Nov 2020
Commented: Walter Roberson on 11 Nov 2020
Hello, I am trying to obtain the string representation of the burmese character given by the unicode number U+103A. But it does not print out, and only gives a box in the figure and the command window, even after using UTF8 as the character set. This unicode number is the exact figure of dotted circle with a solid semi-circle on top of the dotted circle.
How can I save this character as a string? Thanks.
p.s. - I am using other unicodes (in the same dot-m file) which require utf8 as the default character encoding. These ones require a non-English language, which is also the one set in the system Language Preferences. But this is not the Burmese language.
် this is the character.

  3 Comments

Stephen Cobeldick
Stephen Cobeldick on 9 Nov 2020
@v k: what MATLAB version are you using?
v k
v k on 10 Nov 2020
2020a. Thank you for taking interest. I really need to print this character by any means.
Walter Roberson
Walter Roberson on 10 Nov 2020
What did you observe when you ran the test code I posted?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 9 Nov 2020
Edited: Walter Roberson on 9 Nov 2020
So I did some testing... but you will need to do the same tests on your own system to see how it goes.
The characters show up as combined (when the combining character is put after the base character) on the command window when LiveScript is used.
The characters do not show up as other than boxes in the test I did here online, on the experimental facility to display results for you, but when I test on my Mac, the characters show up separately for all fonts except a few of the Lucida fonts (and then they show up as boxes.) I was not able to get the characters to combine on a plot... except by drawing multiple characters at the same position (but then they will not combine properly as the dotted circle will show up, which should not happen when a real combination is done.)
Please test this code on your own system, inside of and outside of Live Script.
B103A = char(0x103A);
B1004 = char(0x1004);
B103A
B103A = '်'
B1004
B1004 = 'င'
S1 = [B103A B1004] %this does not combine, so this is not the proper order
S1 = '်င'
S2 = [B1004 B103A] %this combines, so this is the proper order
S2 = 'င်'
%When I use Livescript, S2 displays in combined form to the command window
%But when I use Mac command window, S2 displays separately.
%I do not have a Windows system handy
%now try plotting with all kinds of fonts
%sorry for all the figures, but this system only displays up to about Ylim 16
FL = setdiff(listfonts(), 'Symbol');
NF = length(FL);
for fidx = 1 : 15 : NF
tF = FL(fidx:min(NF,fidx+14));
fig = figure();
ax = axes('Parent', fig);
for K = 1 : length(tF);
fn = tF{K};
text(1, K, fn + " -> " + S2, 'fontname', fn, 'interpreter', 'tex');
end;
xlim([0 75]); ylim([0 16]);
end

  6 Comments

Show 3 older comments
Walter Roberson
Walter Roberson on 10 Nov 2020
In your utility, how should the statement 'text( ...' be modified so that it uses uicontrol to write, instead of 'text' ?
Here are two different representations in uicontrol. One of them uses just the characters as character codes; on releases up to R2014a this would certainly not render the unicode properly. The second of the ways uses HTML character entities in a uicontrol style listbox; this would be the approach needed up to R2014a (but those earlier releases would be unlikely to render the characters properly... but at least they would have a chance.)
This is for "tradition figures", not for the newer uifigure(); I do not have enough experience with uifigure() to put something like this together in the best way.
Note: using HTML coding for uicontrol will not work for uicontrol style text or style edit, but will work for listbox, popup, radiobox, and pushbutton.
B103A = char(0x103A);
B1004 = char(0x1004);
S2 = [B1004 B103A];
FL = setdiff(listfonts(), 'Symbol');
NF = length(FL);
for fidx = 1 : 15 : NF
tF = FL(fidx:min(NF,fidx+14));
fig = figure();
for K = 1 : length(tF)
fn = tF{K};
uicontrol('Position', [1 K*20 150 15], 'String', fn + " -> " + S2, 'fontname', fn, 'Parent', fig, 'Style', 'text');
end
fig = figure();
for K = 1 : length(tF)
fn = tF{K};
uicontrol('Position', [1 K*25 200 20], 'String', "<HTML>"+fn+" -> &#x1004;&#x103A;", 'fontname', fn, 'Parent', fig, 'Style', 'list');
end
end
v k
v k on 11 Nov 2020
64 (= 2 x 32) plots of empty boxes, and boxes with question marks and 'x' marks inside them ...
But how important is this utility. It eliminates the need to change the font everytime and try the new font. The byproduct of this question is itself of such immense value ...
Walter Roberson
Walter Roberson on 11 Nov 2020
It is disappointing that the controls never seem to render the characters properly at all, and that text() is not able to render the combining codes properly.
The one positive result of this is that it shows that if you are getting just plain emptiness instead of the characters, that changing the font can help to at least get a placeholder.
Note: the 15 fonts per plot was chosen to fit in to the experimental facility I am using to show the results online, which unfortunately does not display large plots without clipping.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!