For Release 2012a (R2012a) and newer, this bug has been fixed. In order to correctly display any non-ASCII characters, the undocumented font option must be used:
publish('myScript.m','format','pdf','font','fontName');
This line will publish 'myScript' into a PDF file using the 'fontName' font. The font used must have the non-ASCII characters used in 'myScript'. For Russian characters, for example, using the 'Candara' font available in Windows 7. If this font is not available, a font with the necessary non-ASCII characters must be installed first.
For product releases prior to R2012a, read below for any possible bug workarounds:
There is a bug in MATLAB 7.13 (R2011b) in the way that PUBLISH handles foreign fonts for publishing PDFs. To work around this issue:
1) Edit the “fop_config.xml” files in the following two locations:
$MATLABROOT\toolbox\shared\rptgen\@rpt_xml\@db_output
$MATLABROOT\toolbox\matlab\codetools\private
Here $MATLABROOT is the MATLAB installation directory that can be found by executing the command MATLABROOT inside the MATLAB command window.
Locate the line that reads "</fonts>" within the “fop_config.xml” files and add the following line just before the "</fonts>" line.
2) From your MATLAB command window, open the “publish.m” file by using the following command:
In this file, locate the line that reads the following:
addAttribute(styleDom,attributeSet,'color','blue')
Add the following lines after the above line in the “publish.m” file:
fontName = '''Arial''';
addVariable(styleDom,de,'body.font.family',fontName)
addVariable(styleDom,de,'dingbat.font.family',fontName)
addVariable(styleDom,de,'monospace.font.family',fontName)
addVariable(styleDom,de,'symbol.font.family',fontName)
addVariable(styleDom,de,'title.font.family',fontName)
addVariable(styleDom,de,'sans.font.family',fontName)
Publishing to PDF files should now work fine after restarting MATLAB.
Best Answer
Please note that, as far as having "&" characters in an XML file, this is technically not supported according to the XML Specification, and a standards-compliant XML encoder should always escape "&" characters. Please refer to the following snippet from the XML Specification (<https://www.w3.org/TR/xml/#syntax>):
"The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings " & " and " < " respectively."
You can use the Unicode notation for the special characters instead of the numerical representation that you used. For instance, the "é" character is represented by the number 233 in Unicode. Please find below a simple example that shows how to write special characters in XML files using Unicode characters.
The code above generates the file "testAccent.xml" which shows as follows: