escodegen icon indicating copy to clipboard operation
escodegen copied to clipboard

The Chinese `(` & `)` are forced to `\uFF08` & `\uFF09`, how to keep them?

Open finscn opened this issue 6 years ago • 2 comments

There are some Chinese chars in my code , example :

var name = "大城小胖(fins)";

I use escodegen.generate to re-generate my code , the string become :

var name = '大城小胖\uFF08fins\uFF09';

How to keep them ?

And I've test , it's not esprima.parse's fault. the string in the AST is original.

version:
"escodegen": "^1.11.0", "esprima": "^4.0.1",


I found (is not , ) is also with this bug.

finscn avatar Nov 17 '18 06:11 finscn

I found it's esutils's bug. It's too old (the last update at 4 years ago)

esutils.code.isIdentifierPartES5 can't work correctly when parse & .

esutils.code.isIdentifierPartES5("大")  ---> true  , it's right
esutils.code.isIdentifierPartES5("(")  ---> false  ,  it's wrong  

, not ( , It's not ascii.

I think escodegen should find a new tool.

finscn avatar Nov 17 '18 07:11 finscn

And I found 2 esutils projects at npmjs :

npm i esutils
npm i @gerhobbelt/esutils

~~I've create a PR to @gerhobbelt/esutils .~~ (wrong PR)

finscn avatar Nov 17 '18 07:11 finscn