- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下摘录引用ECMAScript 2017 .
10.1 源文本、语法
转义序列,如 \u000A
,不会被解释为行终止符(即新行):
In string literals, regular expression literals, template literals and identifiers, any Unicode code point may also be expressed using Unicode escape sequences that explicitly express a code point's numeric value. Within a comment, such an escape sequence is effectively ignored as part of the comment.
ECMAScript differs from the Java programming language in the behaviour of Unicode escape sequences.
If the Unicode escape sequence \u000A occurs within a string literal in a Java program, it is interpreted as a line terminator, which is not allowed within a string literal.
A Unicode escape sequence occurring within a string literal in an ECMAScript program, always contributes to the literal and is never interpreted as a line terminator or as a code point that might terminate the string literal.
11.8.4 字符串文字
代码点可能在字符串文字中显示为转义序列,但反斜线 (\
) 除外。
A string literal is zero or more Unicode code points enclosed in single or double quotes. Unicode code points may also be represented by an escape sequence. All code points may appear literally in a string literal except for the closing quote code points, U+005C (REVERSE SOLIDUS), U+000D (CARRIAGE RETURN), U+2028 (LINE SEPARATOR), U+2029 (PARAGRAPH SEPARATOR), and U+000A (LINE FEED). Any code points may appear in the form of an escape sequence.
问题
\
(11.8.4),转义序列如何出现在字符串文字中?\u000A
不会被解释为行终止符
。这两者看起来很矛盾。如果它不被解释为字符串文字内的换行符,那么它是如何解释的(如果有的话)?最佳答案
How can an escape sequence occur inside a string literal, if \ is not allowed (11.8.4)?
我认为该部分的关键部分是“按字面意思显示”,也就是说字符串文字中的 \
不会转换为结果字符串本身中的反斜杠。这并不是说反斜杠是不允许的,而是说它们不会“按字面意思出现”。
10.1 states that escape sequence \uu000A inside a string literal is not interpreted as a line terminator.
您跳过了那句话的前半部分“总是对文字有贡献”。 \u000A
是完全允许的,并且 确实 会被添加到字符串的内容中。该代码表示它不被视为词法语法意义上的行终止符。据说是这样的
var foo = "one\u000Atwo";
即使如此也是允许的
var foo = "one
two";
是一个语法错误。两者都尝试在单词之间使用换行代码点,但第一个是允许的,因为从词法分析器的 Angular 来看,它实际上并未被视为行终止符。
关于javascript - ECMAScript 2017 : EscapeSequence in StringLiteral,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49635180/
我正在尝试使用beeline从HDFS文件加载表。我已经为此编写了shell脚本,该脚本以StagingSchema.hql文件作为输入并加载了表。 load data inpath ${hivev
以下摘录引用ECMAScript 2017 . 10.1 源文本、语法 转义序列,如 \u000A,不会被解释为行终止符(即新行): In string literals, regular expre
我是 hadoop 和 hive 的新手。我正在尝试将数据加载到配置单元表中,但遇到以下错误。 另一方面,我尝试使用语句 stmt.execute("INSERT INTO employee VALU
我需要创建一个 Eclipse 插件,当我将鼠标悬停在字符串文字上时显示工具提示。但前提是该字符串文字是特殊方法的第一个参数。 这是我用来测试我的插件的 Test.java 文件: package t
我正在使用 Irony DSL 框架来解析一种语言。该语言允许在不使用引号 (") 的情况下编写字符串,即使它们包含特殊字符,如点 (.) 或减号 (-)。 如果我编辑我得到的文本文件,那么字符串周围
我不明白为什么 HIVE 在以下脚本中向我抛出错误: use drop table if exists ; create table like ; load data local inpath
在 iOS 8.0 中我有这个枚举: enum Direction:CGPoint { case Top = "{0, -1}" case Right = "{1, 0}" c
我试图理解字符串文字到最终字符串值(由代码单元值组成)的翻译,遵循 ECMAScript 2017 . 相关摘录 5.1.2 词法和正则表达式语法 A lexical grammar for ECMA
我知道语法 char * = "stringLiteral"; 已被弃用,甚至可能在未来不起作用。我不明白的是为什么。 我搜索了网络和堆栈,尽管有很多回声确认 char * = "stringLite
Java代码: String cmd0 = "hive -e \"use " + hiveuser +
我是一名优秀的程序员,十分优秀!