Special characters in m-files do not carry over to published html

7 views (last 30 days)
I `publish()` quite a bit of m-files to html format for teaching purposes. I (and the students) like to write comments, titles, etc., in French with accentuated letters. I save my m-file with utf-8 encoding. Matlab's `publish` generates a html file with utf-8 character encoding as well but somewhere in the process, accentuated characters have been transformed to rubbish.
For example, the character "é" is transformed to a hard-coded "é" in the html output, which is displayed as "é".
Are there options somewhere to preserve accentuated characters in comments?
Thanks!

Accepted Answer

Dominique
Dominique on 7 Jan 2013
Thanks for the quick reply. I tried 4 variants of UTF-16 and they did not work (either causing Matlab to complain about unrecognized characters or ignoring entire chunks of the file.) On the other hand, other encodings such as Western ISO-8859-15 work. Mac Roman doesn't work (I'm using OSX.)
I guess we'll just have to make an exception for m-files and save them using ISO-8859-15.
Many thanks!

More Answers (1)

Walter Roberson
Walter Roberson on 7 Jan 2013
It appears to be doing a byte-by-byte publication. é is the byte sequence that would be used to encode é in UTF-8
char(unicode2native('é','utf-8'))
As an experiment, could you try saving a copy of the .m file as UTF-16 and publish from that ?

Categories

Find more on File Operations 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!