3

Thanks to Szabolcs' comment to this question, I have found a way to Export Cyrillic symbols from Mathematica to PDF correctly. We just need to set a system-wide variable commonly called the system local (or language for non-Unicode applications) to US English as described here:

  1. Open Regional and Language Options in Control Panel.

  2. On the Advanced tab, under Language for non-Unicode programs, select English (US).

This approach has few usability limitations:

  • Only an administrator has the ability of setting the system locale value.
  • Setting the system locale requires a system reboot.
  • Only one system locale can be set at a time.

Unfortunately, this setting affects not only Mathematica, but every non-Unicode program that is used on the computer including some components of Windows itself. As the result, these programs work incorrectly and in some cases changing this option can even cause a BSOD. For example, the command-line interpreter cmd.exe on localized version of Windows after setting system local to English looks as follows: cmd.exe

For Windows Server 2003 and Windows XP Microsoft developed the Microsoft AppLocale Utility which is intended to allow to run non-unicode applications without changing the system locale (thanks Windows programmer for the reference). But I failed to get it working for Mathematica.

Is it possible to set system locale individually for Mathematica in order to get correct Cyrillic Export to PDF?

EDIT

There is the PDF.exe MathLink executable in the .\SystemFiles\Converters\Binaries\Windows directory. Probably we should set the system locale US English precisely for this executable?

P.S. I use localized Windows XP SP3.

Alexey Popkov
  • 438
  • 4
  • 18
  • If this doesn't get you a solution you might try asking on SuperUser (or flag for migration) as this is less about *Mathematica*. – Mr.Wizard Aug 11 '12 at 05:08
  • @Mr.Wizard Probably you are right, I will flag it for migration on SuperUser. – Alexey Popkov Aug 11 '12 at 22:08
  • From a command prompt, if you run `mode con cp`, what codepage does it report? It must be `866` for Russian. – Be Brave Be Like Ukraine Aug 14 '12 at 14:09
  • @bytebuster Yes, I get `866`. – Alexey Popkov Aug 14 '12 at 14:54
  • Then, you have two items to check: (1) Code page conversion tables, controlled through the `Advanced` tab; (2) font substitutions like `"Arial,0"="Arial,204"` and `"Arial"="Arial,204" ` are missing in registry. – Be Brave Be Like Ukraine Aug 14 '12 at 15:41
  • @bytebuster As I understand, it is not a problem of my system but the problem of *Mathematica* PDF export: it handles cyrillic letters correctly only if the system local is set to US English. And the problem persist for different localized versions of Wondows XP (not only Russian). So probably the only solution is to set system local to US English only for *Mathematica* or don't use localized Windows XP. Or may be it is possible to set system local to US English but configure syctem in such a way that all non-Unicode programs will work correctly? – Alexey Popkov Aug 15 '12 at 06:28
  • It's a valid assumption, but on a screenshot the shell fails to display Cyrillic greeting. I would suggest making the shell to work correctly and then see if Mathematica requires special treatment. – Be Brave Be Like Ukraine Aug 15 '12 at 06:52
  • @bytebuster I presented the screenshot as an illustration of what happens when I set system locale to US English. When it is set to Russsian (as it is by default) everything is OK but *Mathematica* cannot export cyrillic letters correctly. It is documented by Microsoft that changing system locale may casuse such effects. – Alexey Popkov Aug 15 '12 at 07:50
  • @Mr.Wizard Surprizingly, the problem can be solved without leaving *Mathematica*... – Alexey Popkov Nov 30 '12 at 16:14
  • Yes, I am surprised. Thanks for sharing your solution. – Mr.Wizard Nov 30 '12 at 16:59

1 Answers1

1

It seems that the problem can be solved by setting explicit value of the CharacterEncoding global FE option (checked with MMa 8.0.4 and 9.0.0):

SetOptions[$FrontEnd, CharacterEncoding -> "UTF8"];
Export["test.pdf", "кириллический текст"]

An equivalent way (without changing the global FE settings):

Export["test.pdf", 
 Style["кириллический текст", CharacterEncoding -> "UTF8"]]

Instead of "UTF8" one may set "UTF-8" or "ASCII" with the same effect. The drawback of this approach is that all non-English letters are outlined.

Alexey Popkov
  • 438
  • 4
  • 18