-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
un-ascii string should not escape. #10
Comments
Unicode escaping works as intended. In this case the extra backslashes are there because the python repl outputs a representation of the string to your terminal rather than the string itself: >>> 我 = String('我')
>>> str(我)
'"\\\\u6211"'
>>> print(repr(str(我))) # This is the code that the repl executes
'"\\\\u6211"' If you want to display the actual nbt literal you just need to print the string directly: >>> print(str(我))
"\\u6211"
>>> print(我) # The `print` function internally calls `str`
"\\u6211" |
Oh right my mistake I tested it with json text objects so I didn't realize that the reason why the escape sequence worked was because it was interpreted afterwards by the json parsing: >>> print(Compound({'display': Compound({'Name': String('{"text":"我"}')})}))
{display:{Name:"{\"text\":\"\\u6211\"}"}} So yeah I tried it out in a command and it worked:
Anyway since bare strings seem to support unicode characters directly I think I'll just get rid of the escaping. |
Alright escaping problems should be fixed in 97efa25. |
Closing the issue as the fix is now in release 1.3.1. |
>>> str(nbtlib.tag.String("我"))
'"\\\\u6211"'
as NBT String only support \" and \\ escape.
The text was updated successfully, but these errors were encountered: