How can I insert unicode characters into Published html?

2 views (last 30 days)
I've started using the "Publish" feature again for creating tutorial and exam question solutions. Its very handy, now that there is a way to make the Latex equations come out bigger (and readable!). ( Thread 163367 )
Now, the next issue I am trying to solve is how to get some unicode characters into the published html, to represent (for example), the Ohms symbol Ω or the angle symbol ∠
The trouble is, when I try and insert these into the MATLAB script and publish, it (you may say correctly) "escapes" the & character as & and so Ω comes out as Ω in the published html and this of course then appears in the web browser as Ω again.
An ugly solution is to post-edit every html file and strip out the &'s and replace them with just & again.
But, is there some way of stopping MATLAB adjusting the &'s to &'s?
In my MATLAB script, I am trying to use lines like:
I1_answer = [MFAJR_SigFigStr(abs(I1),2),' ∠ ',MFAJR_SigFigStr(180/pi*angle(I1),2),'° Amps RMS (angle relative to V1)']
I am hoping to get something like this in the final browser window
I1_answer =
2.2 ∠ -90° Amps RMS (angle relative to V1)
But I am actually getting
I1_answer =
2.2 ∠ -90° Amps RMS (angle relative to V1)
Any ideas?
By the way, writing this thread took a long time because the forum software keeps evaluating the & codes and I had to double-code all the ampersands. I think it looks right in the final preview/view now..

Answers (1)

Andrew Roscoe
Andrew Roscoe on 24 Jan 2014
I have tried doing all sorts of things, even wrapping the unicode inside html tags, i.e. html∠</html>, but MATLAB converts < and > to its web-compliant string as well if these are anywhere other than in a "comment" line. I guess the html markup only works inside a line that starts with % (comment lines).
The only solution I can find is to post-process the html files that MATLAB produces. I have these 3 lines in a DOS batch file (and Perl installed on my PC). These work for the 2 symbols I really want just now. I guess I will need to add more lines if I add more symbols. Ugly!
for /f %%a IN ('dir /b *.html') do perl -pi.orig -e "s/&ang;/&ang;/g;" %%a
for /f %%a IN ('dir /b *.html') do perl -pi.orig -e "s/&Omega;/&Omega;/g;" %%a
pause

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!