-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
The escape sequence \uD is not valid code point #26620
Comments
Dart string literals only allow valid code points, not individual code units. That made more sense when Dart strings were code point sequences, but now that they are UTF-16 code unit sequences, we might want to reconsider it. There are workarounds. For |
I think this is somewhat inconsistent. There are definitely some tests that do produce this, and it's valid in JavaScript, so I think we had removed some similar checks in Dartium. It was last August, but I can't seem to find the CL right now. |
I also tried using |
That won't work either, it means exactly the same thing. You can't have a single code point in the range U+D800..U+DFFF in a string literal. It's not a valid UTF-16 sequence, and string literals can only generate valid Unicode strings.
because a Unicode scalar value is any code point except the surrogate code points. It's somewhat inconsistent because you can actually create string literals containing unpaired surrogates, as long as you encode them directly in the UTF-8 source file without using escapes. Mind you, I'm not saying it isn't annoying. I usually only hit it while writing unit tests. If you are using strings to store binary data then you get into problems much easier (you might want to just store values in the range 0.255 then, both the VM and most JavaScript engines have special treatment of Latin-1 strings).. |
I note that it works fine in dart2js, although the analyzer claims there's an error. |
Fixes issue #26620 BUG: http://dartbug.com/26620 R=asiva@google.com, brianwilkerson@google.com, floitsch@google.com, hausner@google.com, sigmund@google.com Review URL: https://codereview.chromium.org/2304923002 .
Fixes issue #26620 BUG: http://dartbug.com/26620 R=asiva@google.com, brianwilkerson@google.com, floitsch@google.com, hausner@google.com, sigmund@google.com Review URL: https://codereview.chromium.org/2304923002 . Committed: 574ae43
When creating string that contains unicode between
\uD800
and\uE000
I get next error:For example having this code:
throws me an error similar to this:
My Operating system is Linux Mint 17.3 and dart version is
1.17.0-dev.6.4
The text was updated successfully, but these errors were encountered: