renciso218 / blockly

Automatically exported from code.google.com/p/blockly
0 stars 0 forks source link

Encoding non-ASCII variables for generator #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. use some non-ASCII word as variable
2. the generated code shows '__' instead of the non-ASCII word

approach:

We can use 'encodeURI' to escape non-ASCII variables to ASCII code

== get ==

from 

variableDB_.getName(this.getTitleText(1)

to 

variableDB_.getName(encodeURI(this.getTitleText(1))

== set ==

from 

variableDB_.getName(this.getTitleText(1)

to 

variableDB_.getName(encodeURI(this.getTitleText(1))

Original issue reported on code.google.com by gasolin on 9 Jun 2012 at 6:38

GoogleCodeExporter commented 8 years ago
BTW the ASCII variable will not change after apply this patch. 

Note that the generated variable is not exactly the non-ASCII variables, but a 
'A1_B3_12' style variable.

Since python(2.x) and other language may not support non-ASCII variables 
natively, a 'A1_B3_12' style variable might be the best compromised choice.

Original comment by gasolin on 9 Jun 2012 at 7:25

GoogleCodeExporter commented 8 years ago
Good call.  I've added this to names.js so that it applies to all the places 
where variables are used, as well as function names.  Revision 226.  Pushed to 
Subversion, and will be in the next production push.

Original comment by neil.fra...@gmail.com on 9 Jun 2012 at 8:06