Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 所有的转义字符是什么?_Java_String_Escaping - Fatal编程技术网

Java 所有的转义字符是什么?

Java 所有的转义字符是什么?,java,string,escaping,Java,String,Escaping,我知道Java中的一些转义字符,例如 \n : Newline \r : Carriage return \t : Tab \\ : Backslash ... 某处有完整的列表吗?你可以找到完整的列表 \t此时在文本中插入一个选项卡 \b此时在文本中插入一个空格 \n此时在文本中插入换行符 \r此时在文本中插入回车符 \f此时在文本中插入一个formfeed \'此时在文本中插入一个引号字符 \”此时在文本中插入双引号字符 \\此时在文本中插入反斜杠字符 这是0x0000-0xFFFF(

我知道Java中的一些转义字符,例如

\n : Newline
\r : Carriage return
\t : Tab
\\ : Backslash
...

某处有完整的列表吗?

你可以找到完整的列表

  • \t
    此时在文本中插入一个选项卡
  • \b
    此时在文本中插入一个空格
  • \n
    此时在文本中插入换行符
  • \r
    此时在文本中插入回车符
  • \f
    此时在文本中插入一个formfeed
  • \'
    此时在文本中插入一个引号字符
  • \”
    此时在文本中插入双引号字符
  • \\
    此时在文本中插入反斜杠字符

这是0x0000-0xFFFF(0-65535)中的unicode值。其他平面只能用多个字符在Java中指定:埃及继承人A054(laying-down dude)是
U+1303F
/
𓀿;
,必须分解为
“\uD80C\uDC3F”
(UTF-16)对于Java字符串。一些其他语言支持更高的平面,带有
“\U0001303F”

是的,下面是docs.Oracle的链接,您可以在其中找到Java中转义字符的完整列表

转义字符总是前面加“\”,用于执行某些特定任务,如转到下一行等

有关转义字符的更多详细信息,请参阅以下链接:


这些是用于操纵字符串的转义字符

\t  Insert a tab in the text at this point.
\b  Insert a backspace in the text at this point.
\n  Insert a newline in the text at this point.
\r  Insert a carriage return in the text at this point.
\f  Insert a form feed in the text at this point.
\'  Insert a single quote character in the text at this point.
\"  Insert a double quote character in the text at this point.
\\  Insert a backslash character in the text at this point.
从这里了解更多关于他们的信息


这是在“不要在互联网上问问题”中,你可以同样轻松地或更轻松地自己查找。你可能会遇到严重错误。该列表缺少Unicode和八进制转义:\u1234\012\01\0这是它还缺少贝尔字符
\a
和空字符
\0
\a
不在javac 1.8.0中编译:
非法转义字符:String test=“\a”
“Unicode转义在编译器运行之前进行预处理。" -- . 因此,它们不同于此处列出的标准字符串转义。感谢Jan对现有答案的评论,该答案没有解决Java中的unicode和八进制转义序列。
\u000a
似乎不起作用->
-无效字符常量
请参阅更多@Jan它可能工作得太好了。例如,与
\r
\n
不同,unicode转义是在编译器运行之前进行预处理的,正如您链接到的问题所指定的那样。因此,它在代码中插入一个文本换行符,并因此而失败。然而,转义码是“工作”的,因为它是在规范中工作的。
\t  Insert a tab in the text at this point.
\b  Insert a backspace in the text at this point.
\n  Insert a newline in the text at this point.
\r  Insert a carriage return in the text at this point.
\f  Insert a form feed in the text at this point.
\'  Insert a single quote character in the text at this point.
\"  Insert a double quote character in the text at this point.
\\  Insert a backslash character in the text at this point.