程序员需要哪些报价?
我的键盘只有普通引号,没有智能引号。
我发现我在 CGI 开发 中需要普通的AWK 中的向后的/SED。
当我应该使用智能引号、普通引号和后向引号时,有什么规则吗?
显然,我需要编辑键盘布局才能获得智能引号。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我的键盘只有普通引号,没有智能引号。
我发现我在 CGI 开发 中需要普通的AWK 中的向后的/SED。
当我应该使用智能引号、普通引号和后向引号时,有什么规则吗?
显然,我需要编辑键盘布局才能获得智能引号。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
如果您的意思是智能引号中的
`
,那么这实际上称为“反引号”。 智能引号是指当您键入 ' 和 " 时,但会根据上下文自动获取 ' and ' 或“ and ”。我不确定如何在 awk 或 sed 中使用智能引号。在 shell 中,反引号,例如 < code>`command`,用于计算命令并将其中命令的结果替换为正在计算的 shell 表达式;它可用于计算和传递给另一个命令,或设置变量。 更容易计算出许多引用规则。
为了减少歧义,您可以使用
$(command)
,这使得在 shell 中,'
和"< /code> 也不同。
"
用于需要变量替换和转义序列的字符串。'
表示仅包含引号内的字符的字符串,不包含变量插值或转义序列。因此,例如:
其他脚本语言,例如 Perl 和 Ruby,也有类似的规则,尽管可能存在细微的差异。
If you mean
`
by smart quotes, then that is actually called "backquote". Smart quotes are when you type ' and ", but get ‘ and ’ or “ and ” automatically depending on the context. I'm not sure how you would use smart quotes in awk or sed.In the shell, backquotes, such as
`command`
, are used to evaluate a command and substitute the result of the command within them into the shell expression being evaluated; it can be used to compute and argument to another command, or to set a variable. For less ambiguity, you can instead use$(command)
, which makes a lot of quoting rules easier to work out.In the shell,
'
and"
are also different."
is used for strings in which you want variable substitution and escape sequences.'
represents a string containing just the characters within the quotes, with not variable interpolation or escape sequences.So, for example:
Other scripting languages, such as Perl and Ruby, have similar rules, though there may be slight differences.
智能引号用于漂亮的排版。 它们与编程无关。
编辑:您确实需要的报价。
'"foo"'
)echo
``date\
可能会执行 echo Sat Mar 1 09:43:00 GMT 2008 并打印 Sat Mar 1 09:43:00 GMT 2008。Smart quotes are for beautiful typesetting. They have nothing to do with programming.
Edit: the quotes you do need.
'"foo"'
)echo
``date\
might execute echo Sat Mar 1 09:43:00 GMT 2008 and print Sat Mar 1 09:43:00 GMT 2008.反引号在 shell、AWK 和 Perl 编程,以及在 TeX。 除此之外,您可能不会经常使用它们。
Backticks are used a lot in shell, AWK, and Perl programming, and when doing documents in TeX. Other than that, you probably won't use them much.
聪明的引言是魔鬼。
Smart quotes are the devil.
据我所知,没有语言需要(或者甚至不一定支持)“智能引号”,除非您将反引号字符 ` 称为智能引号。 如果是这种情况,许多语言都支持反引号。 例如, Bash 和 Ruby 使用反引号进行命令替换。
要回答这个问题,当我应该使用智能引号和普通引号时是否有任何规则?,是的,有一个规则(再次假设您说“智能引号”时指的是反引号)。 在大多数语言中,不同类型的引用会带来不同类型的行为。 规则是,了解该特定语言的行为是什么,然后选择给出该行为的引用。
As far as I know, no language requires (or necessarily even supports) "smart quotes" unless you are calling the backtick character, `, a smart quote. If that's the case, many languages support the backtick. For example, both Bash and Ruby use the backtick for command substitution.
To answer the question Is there any rule when I should use smart quotes and normal ones?, yes, there is a rule (again, assuming you mean the backtick when you say "smart quotes"). In most languages, different types of quoting give you different types of behavior. The rule is, learn what the behavior is for that particular language, and then pick the quote that gives you that behavior.
智能引号是文字处理功能。 当您输入“quote”时,它会自动替换为“quote”或“quote”。 我认为你的命名法有误。
Smart quotes is word processor feature. When you type "quote" it gets automatically replaced with “quote” or „quote”. I think you got your nomenclature wrong.
仅供参考,“智能引号”的另一个术语(我以前从未听说过)是严重的口音。
我认为之前的答案中已经非常清楚地列出了规则。
Just an FYI, another term for 'smart quotes' (which I have never heard of that before), is grave accent.
I think the rules have been laid out pretty clearly in previous answers.