UnicodeEscape: UnicodeMarker HexDigit HexDigit HexDigit HexDigitUnicodeMarker: u UnicodeMarker u 转换为 \u+p{XDigit}{4}和如果一个符合条件的 后面跟有 u,或者超过一个 u,并且最后一个 u 后面没有跟四个十六进制数字,那么就会发生编译时错误.If an eligible is followed by u, or more than one u, and the last u is not followed by four hexadecimal digits, then a compile-time error occurs.所以你是对的,反斜杠后面可以有一个或多个 u.原因如下:So you're right, there can be one or more u after the backslash. The reason is given further down:Java 编程语言指定了将用 Unicode 编写的程序转换为 ASCII 的标准方法,该方法将程序更改为可由基于 ASCII 的工具处理的形式.转换涉及通过添加额外的 u 将程序源文本中的任何 Unicode 转义转换为 ASCII - 例如,uxxxx 变为 uuxxxx - 同时将源文本中的非 ASCII 字符转换为每个包含一个 u 的 Unicode 转义.The Java programming language specifies a standard way of transforming a program written in Unicode into ASCII that changes a program into a form that can be processed by ASCII-based tools. The transformation involves converting any Unicode escapes in the source text of the program to ASCII by adding an extra u - for example, uxxxx becomes uuxxxx - while simultaneously converting non-ASCII characters in the source text to Unicode escapes containing a single u each.这个转换后的版本同样可以被 Java 编译器接受,并且代表完全相同的程序.稍后可以通过将每个存在多个 u 的转义序列转换为一个少一个 u 的 Unicode 字符序列,同时将每个带有单个 u 的转义序列转换为相应的单个 Unicode 字符,从而从这种 ASCII 格式中恢复确切的 Unicode 源.This transformed version is equally acceptable to a Java compiler and represents the exact same program. The exact Unicode source can later be restored from this ASCII form by converting each escape sequence where multiple u's are present to a sequence of Unicode characters with one fewer u, while simultaneously converting each escape sequence with a single u to the corresponding single Unicode character.所以这个输入 u0020ä变成 uu0020u00e4第一个 uu 在这里的意思是这是一个以 Unicode 转义序列开头的";而第二个 u 说一个自动工具将非 ASCII 字符转换为 unicode 转义字符."The first uu means here "this was a unicode escape sequence to begin with" while the second u says "An automatic tool converted a non-ASCII character to a unicode escape."当您想从 ASCII 转换回 unicode 时,此信息很有用:您可以尽可能多地恢复原始代码.This information is useful when you want to convert back from ASCII to unicode: You can restore as much of the original code as possible. 这篇关于Java 中的 Unicode 转义语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!