Tag Info

Hot answers tagged

17

Since a native method is not forthcoming, I shall post my file based circumvention, for Windows. You will need to have this utility in the command path (it apparently is stock with Windows 7). copyUnicode[expr_] := Run["clip <", Export["$Clipboard.temp", ToString[expr, InputForm], "Text", CharacterEncoding -> "Unicode"] ]; Usage: expr ...


11

Here are two functions that'll do what you need. putClipboardImage[img_Image] := Module[{nb}, nb = CreateDocument[{}, Visible -> False, WindowSelected -> False]; NotebookWrite[nb, Cell[BoxData@ToBoxes@Image[img, Magnification -> 1]]]; SelectionMove[nb, All, CellContents]; FrontEndTokenExecute[nb, "CopySpecial", "MGF"]; ...


11

Declaration: This method for Windows is based on the .NET code from Todd Gayley's this wonderful answer. My .NET knowledge is absolutely ZERO, all credit goes to Todd. Code: The main idea is to extract the "Input"-style code string, convert it to the UTF-16 little endian form, which is the standard byte order in Windows, feed the bytes to system clipboard ...


9

Edit Fixed problem with pasting into textarea In some applications on Mac, copying as Unicode from Mathematica already works without having to do any postprocessing. However, it doesn't work in textarea fields in web browsers. Nevertheless, if you're willing to do a few additional mouse clicks, the Unicode forms can be brought into the browser by taking ...


6

Here's a version that doesn't require a temporary file. Linux (needs xclip) SetAttributes[copyUnicode, HoldAll]; copyUnicode[expr_] := With[{ stream = OpenWrite["!xclip -in -selection clipboard", CharacterEncoding -> "UTF-8"] }, WriteString[stream, ToString[Unevaluated@expr, InputForm]]; Close@stream; ]; Example: executing the cell ...


3

If you look at the internal expression of the cell containing the image, you'll find that it also uses the compressed form. However, the usual trick of Cell@BoxData@ToBoxes... doesn't seem to work here, as that only gives us the RawArray representation. This gives us a hint at a possible way of retrieving the compressed representation without having to build ...


1

This works for me: boxes = ToBoxes@Graphics@Raster[RandomReal[{0, 1}, {5, 5}]] (* ==> GraphicsBox[ RasterBox[{{0.0429951, 0.153342, 0.815801, 0.825589, 0.178414}, {0.732659, 0.659418, 0.871481, 0.644735, 0.54453}, {0.499096, 0.328874, 0.40405, 0.436912, 0.0551782}, {0.824125, 0.889256, 0.249706, 0.562126, 0.408294}, {0.612762, ...


1

This is a possible solution that I came up with after looking at another answer by @Ragfield: Encoding format used by GraphicsData? I had to modify the function decodePICT in that post to cut out the leading zero bytes: DecodePDF[data_String] := Module[{slash, backslash, zero, LF, CR, decode, codes, len, i}, {slash, backslash, zero, LF, CR} = ...



Only top voted, non community-wiki answers of a minimum length are eligible