2
$\begingroup$
FromCharacterCode[8734]
(* ∞ *)

No matter how I copy whether as plaintext or input text or whether it is inside string like "∞" Mathematica always copy it as \[Infinity]. Even when I use CopyToClipboard instead of manual copying.

So everything I transfer from Mathematica here on this site looks ugly:

you get

"123\[Infinity]456"
{1,2,3,\[Infinity],4,5,6}
Integrate[f[x],{x,-\[Infinity],\[Infinity]}]

instead of

"123∞456"
{1,2,3,∞,4,5,6}
Integrate[f[x],{x,-∞,∞}]

All instances of here in this question I had to manually overwrite with symbol that I copied from web browser.

So evidently it is possible to copy and paste correctly.

Furthermore when I copy from here and paste it in Mathematica then Mathematica interprets it correctly same as it would \[Infinity].

So definitely Mathematica recognize it correctly when copied and pasted from somewhere else yet it is unable to do opposite - copy it inside Mathematica and paste it literally somewhere else.

So my question is how to copy inside Mathematica so that after being pasted here it remains and not \[Infinity].

Update:

I figured out the bytes that are put into clipboard when copying in Mathematica:

FromCharacterCode[{92,91,73,110,102,105,110,105,116,121,93}]

(* \[Infinity] *)

But other software like web browser put into clipboard these bytes:

FromCharacterCode[{226,136,158},"UTF8"]

(* ∞ *)

Mathematica interprets both sequences of bytes inside clipboard as infinity after being pasted but when copying it uses only first sequence.

So if we can write bytes data into clipboard with Mathematica then that would be an answer for my question.

$\endgroup$
5
  • 1
    $\begingroup$ Maybe this question belongs on meta. Here's an answer of sorts: mathematica.meta.stackexchange.com/questions/1043/… $\endgroup$
    – Michael E2
    Aug 23, 2022 at 11:22
  • 2
    $\begingroup$ See Additional useful buttons for our M.SE editor or, if you can't install the add-in (eg on mobile), try the Mathematica Special Character Converter at steampiano.net/msc. $\endgroup$
    – MarcoB
    Aug 23, 2022 at 11:22
  • $\begingroup$ @Michael E2: It is question on Mathematica - precisely, how to put into clipboard using Mathematica. If my web-browser can do it and Mathematica understands it when it is pasted into it, then Mathematica should be able to do the same. Maybe if there is a way to put something into clipboard based on bytes - something like BinaryWrite but writing into clipboard instead of file. $\endgroup$ Aug 23, 2022 at 12:35
  • 1
    $\begingroup$ But "after being pasted here" makes it about how to use the site, a question appropriate for meta.Mma. Maybe you should clarify what you want (by editing the question). $\endgroup$
    – Michael E2
    Aug 23, 2022 at 12:38
  • $\begingroup$ I updated my question. I think it is a question that can belong to both topics. $\endgroup$ Aug 23, 2022 at 13:29

1 Answer 1

0
$\begingroup$

Here is a solution that uses Python and PyClip inside Mathematica. expression is expression needed to be copied into clipboard and rules are rules for replacing certain symbols like or π...

expression=Integrate[\[Pi]+f[x],{x,-∞,∞}];
rules={"Infinity"->"∞","Pi"->"π"};
ExternalEvaluate["Python","import pyclip\npyclip.copy(\""<>(StringReplace[ToString[expression],rules])<>"\")"]
Clear[expression,rules]

Then using Paste[] returns in Mathematica (as desired):

Integrate[π + f[x], {x, -∞, ∞}]

Or pressing CTRL+V in windows in webbrowser paste as desired:

Integrate[π + f[x], {x, -∞, ∞}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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