mojira.dev
MC-311872

Some character names are not parsed by the SNBT Unicode name parser

Steps to Reproduce

  1. Run the command in chat: /tellraw @s "\N{LINE FEED (LF)}"

Expected Result

Prints a line feed character (\n).

The name can be verified in jshell:

jshell> Character.getName('\n')
$1 ==> "LINE FEED (LF)"

Observed Result

The command doesn’t parse.

The error message is:

Expected literal }
...LINE FEED (LF)}"<--[HERE]

Code Analysis

In SnbtGrammar.java:

private static final Pattern UNICODE_NAME = Pattern.compile("[-a-zA-Z0-9 ]+");

The pattern is too strict so it doesn’t parse the parentheses.

Comments 2

Is there any implementation anywhere that will parse that correctly? While “LINE FEED” and “LF” are both valid names for U+000A, “LINE FEED (LF)” is not. Unicode character names cannot contain parentheses. Whatever jshell is doing, it’s not returning a formally defined identifier.

Reply to the comment above.

JShell is the REPL tool of Java.

Character.getName returns the character name used by Java.

The other way (Character.codePointOf) is used by SnbtGrammar and can also be confirmed to use “LINE FEED (LF)”.

jshell> Character.codePointOf("LINE FEED (LF)")
$1 ==> 10

merak48763

(Unassigned)

Confirmed

Platform HC

Low

Commands

26.3

Retrieved