For several decades, the clipboard feature supported by all mainstream operating systems has functioned as a method of exchange between applications (not just within them), by serving as a kind of clearinghouse for formats potentially useful to recipient applications. In this model it is the source application's responsibility to provide formats of general utility to recipient applications, particularly basic textual and Unicode representations.

For example, if I copy an image from my Web browser, the clipboard includes not only several different image formats (e.g. BMP, TIFF, etc.) but also textual formats (both plain text and Unicode) that can be used by recipient applications unable to make sense of the image formats. In this case, a URL from where the image can be retrieved.

Mathematica however does not do this.

If, for example I copy

abcdefg 

from a Notebook, the clipboard does not contain any textual format of use to a text-based recipient application, but instead has three textual formats, all of which contain

a\\
b\\
c\\
d\\
e\\
f\\
g

which is entirely useless almost everywhere.

Mathematica seems to offer a simple though somewhat awkward workaround in the form of a "Copy as Text..." command (and a corresponding keyboard shortcut). But this doesn't work as required either: for example

αβγδϵ

copied "as text" puts

\[Alpha]\[Beta]\[Gamma]\[Delta]\[Epsilon]

on the clipboard in all textual formats (including "unicode"!)! And simply copying is even worse, causing Mathematica to freeze when a paste is attempted, and yielding

α\
β\
γ\
δ\
ϵ

only after Mathematica (and in some cases the receiving application as well) has been terminated (by "Force Quitting")!

This is so nonsensical (did Wolfram miss the memo from the 80s about how clipboards work?) that there must be something I'm missing: How do I configure Mathematica to support standard clipboard behavior?


Note that a version (sort of the reverse) of this odd clipboard behavior occurs even outside the Notebook interface. If I use the Mathematica shell in my command line program (Terminal on OS X), while I can copy text like αβγδϵ from the shell to other applications as expected, copying within the Mathematica shell fails entirely: nothing appears at all when I paste!


For anyone interested in exploring these oddities more deeply, on OS X, simply run the clipboard as record in any AppleScript tool after copying from Mathematica.

  • As an interim measure, it might be useful to know that Save As... in plain text format seems to perform the correct unicode translations, producing output which when viewed in the TextEdit app looks very similar to the notebook's appearance in Mathematica. – Ralph Dratman Dec 23 '15 at 1:44
  • This bug persists in version 11, and appears to have worsened. Copying from MMA and switching go other apps (e.g. any JetBrains IDE, Pages, etc.) causes both MMA and the app to freeze and require a force-quit. – orome Sep 3 '16 at 13:34
  • The copy and paste crash behavior also occurs in other apps (e.g. copying from MMA to Safari crashes both apps fatally). – orome Oct 8 '16 at 13:45
  • This bug persists in 11.1. – orome Mar 23 '17 at 16:37
  • This bug persists in 11.1.1.0. – orome Sep 6 '17 at 18:23

The Mathematica internal format for special characters (such as Greek letters) seems to be completely different from Unicode or any other agreed-upon encoding standard. My advice is to forget about copy and paste of non-Ascii characters from Mathematica to or from any other program. You can lessen the bother of this by just writing, for example, "alpha" in ordinary letters instead of using the Mathematica alpha character. I usually do that anyway, because it annoys me to press special key codes just to make some equation look the way it does in the textbook.

  • But it doesn't even work for basic characters. – orome Oct 10 '16 at 3:13
  • I just copied the code fragment myNotebook=SetSelectedNotebook[thisNotebook] and pasted it into the Mac Notes app with no trouble. MacOS 10.11.6 Mathematica for MacOS 11.0.0.0 – Ralph Dratman Oct 10 '16 at 4:39
  • m\ y\ N\ o\ t\ e\ b\ o\ o\ k\ \ = S\ e\ t\ S\ e\ l\ e\ c\ t\ e\ d\ N\ o\ t\ e\ b\ o\ o\ k\ [ t\ h\ i\ s\ N\ o\ t\ e\ b\ o\ o\ k\ ] – orome Oct 10 '16 at 13:20
  • That's what I get, one character per line. And that's exactly what I see on the clipboard with a clipboard inspector. There's now way that's what should be there. – orome Oct 10 '16 at 13:21

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.