niklasvh / php.js

PHP to JavaScript converter and VM written in JavaScript
http://phpjs.hertzen.com
MIT License
860 stars 115 forks source link

error for CJK variable name #50

Open gallex opened 10 years ago

gallex commented 10 years ago

When use CJK char as variable name in PHP, it would error. I found the reson is it use regular expression /^\$[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff]*/ to match variable , but JS string is unicode so the match would fail.

I suggest to use /^\$[a-zA-Z\u4E00-\u9FA5][a-zA-Z0-9\u4E00-\u9FA5]*/ .