将代码从Mathematica复制到其他平台的已知问题? [英] Known issues with copying code from Mathematica to other platforms?

查看:91
本文介绍了将代码从Mathematica复制到其他平台的已知问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是注意到,如果您在MMA(8.0.1/win7-64)中具有此功能:

I just noticed that if you have this in MMA (8.0.1 / win7-64):

并将其复制到SO(仅按ctrl-c ctrl-v),您将得到以下信息:

and you copy it to SO (just ctrl-c ctrl-v), you get this:

(maxY - minY)/stepy/(maxX - minX)/stepx  

在数学上不等效.应该是这样:

((maxY - minY)/stepy)/((maxX - minX)/stepx)

或此(上面的InputForm):

((maxY - minY)*stepx)/((maxX - minX)*stepy)

这不是由StackOverflow内部造成的,与复制到NotePad的情况相同.

It's not caused by StackOverflow's internals as the same happens with a copy to NotePad.

还有更多这样的问题(尤其是在使用SO时,但一般来说),我们应该意识到吗?

Are there more issues like this (especially when working with SO, but also in general) that we should be aware of?

是什么原因造成的,可以将它固定在我们这一边吗?如果没有,最好的解决方法是什么?

What causes this, can it be fixed on our side, and if not, what is the best work-around?

推荐答案

将Mathematica代码复制到Usenet Mathematica组有时会在您的代码中分散各种奇怪的字符(您不知道何时会发生这种情况).解决方法是:

Copying Mathematica code to the Usenet Mathematica group sometimes scatters all kinds of weird characters throughout your code (you never knew when it would happen to you). The workaround would be either:

  1. Cell > Convert To > InputForm,然后进行复制

Edit > Copy As > Plain TextInput Text

在这种情况下,后者不起作用.您仍然会获得数学上不正确的转换.前者确实有效.

The latter doesn't work in this case. It's still a mathematically incorrect conversion that you'll get. The former does seem to work.

更新
如果您在Mathematica新闻组的帖子中遇到过奇怪的字符(例如,如在这里),以下功能将对其进行解码(在我测试过的所有情况下).

Update
If you ever encounter strange characters in posts in the Mathematica newsgroup (e.g., as in here) the following function will decode it (in all the cases that I tested).

translateQuotedPrintable[str_String] := 
  StringReplace[str, {"=" ~~ c1:HexadecimalCharacter~~c2:HexadecimalCharacter :> 
    FromCharacterCode[FromDigits[c1 <> c2, 16], "Math1"],"=" ~~ EndOfLine -> ""}]

只需将整个帖子粘贴在translateQuotedPrintable[" ... "]中的引号之间,即可清除该帖子.

Just paste the whole posting between quotes in translateQuotedPrintable[" ... "] and the post will be cleaned up.

出于好奇:您可能会在这些Usenet帖子中看到的编码称为引用可打印的.它用于将不同于标准7位ASCII设置的字符编码转换为ASCII.如果许多先前未通过InputForm cs转换为ASCII的通用MMA符号(例如规则符号),则会以这种方式进行编码.要解码代码,需要知道原始字符集,因为QP仅产生字符集中的十六进制位置.对于MMA,通常是Math1.

For the curious: the encoding that you may see in these usenet postings is called Quoted Printable. It is used to convert character encodings that differ from the standard 7-bit ASCII set to ASCII. Many common MMA symbols, like the Rule symbol, are encoded this way if not previously converted to ASCII by InputForm cs. To decode a code one needs to know the original character set because QP only yields the hexadecimal position in the character set. In MMA's case this will most commonly be Math1.

这篇关于将代码从Mathematica复制到其他平台的已知问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆