-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 characters? #531
Comments
The precise formatting of string literals is not preserved, only their content (with escape sequences resolved) is. To preserve original source code formatting (including string literals), https://github.com/nikic/PHP-Parser/blob/master/doc/component/Pretty_printing.markdown#formatting-preserving-pretty-printing can be used. |
Just to be clear, the generated code still has exactly the same meaning -- none of the characters will be corrupted, they're just no longer written using hex escape sequences. Though it may be that the code is corrupted after being modified by a text editor which replaces broken UTF-8. |
An alternative to the full formatting-preserving printer is https://github.com/nikic/PHP-Parser/blob/master/doc/component/Lexer.markdown#attribute-handling and extending the pretty printer to use the originalValue attribute. Especially if you know that none of your transformations modify string contents, this would be a quick fix. |
-> thanks @nikic -> nikic/PHP-Parser#531 -> wait for fix -> nikic/PHP-Parser#532
Big thanks for the help and for your work, it works pretty good (voku/7to5@7a62d12) :) but now I have a different problem... ... after converting a class from PHP7 -> PHP5 there was a different behavior in "if"-conditions, so I tried to fix it, with this "hack": -> #532 |
Hi, in this issue spatie/7to5#40 I tried to figure out what goes wrong and I found that the "String_" class breaks the unicode chars, but why and how can I disable this behavior? Thanks!
lib/PhpParser/Node/Scalar/String_.php:
-->
... becomes ...
The text was updated successfully, but these errors were encountered: