-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Unicode Variables #1654
Comments
This doesn't appear to be occuring at a JavaScript specific level. (/me sneaks away for it can be reassigned.) |
Yup, it's in
A quick check of Dart, Lua and Python 2 shows that they do not support Unicode variables, though Python 3, JavaScript and PHP do. There's a feasible way to implement this in JavaScript:
where x is the first letter then the first two letters, then the first three letters of the name. If it blows up, then encode the offending letter. Also, '/n' and '/r' and ';' need to be escaped up front to prevent injection attacks. |
Feasible, yes, but not exactly sensible, as the list of characters that would need to be escaped first is longer than just A better approach is probably to use a regexp, even though the required regexp 8-10kB long and depends on what version of ECMAScript and Unicode one is targeting. |
Current behaviour
Blockly variables have their Unicode characters encoded. Thus the variable '中国' is turned into '_E4_B8_AD_E5_9B_BD'. Such JavaScript is legal, but completely unreadable.
Expected behaviour
It turns out that Unicode characters are allowed in JavaScript variable names.
Or:
Here's documentation regarding what is and isn't allowed:
https://mathiasbynens.be/notes/javascript-identifiers
The text was updated successfully, but these errors were encountered: