-
Notifications
You must be signed in to change notification settings - Fork 57
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
Specify encoding #34
Comments
@weirdan Thank you for reporting this issue. I am trying to find a way to access the document encoding from vscode but have not found a solution yet. I will open a ticket with the language server guys and hope to resolve the issue. |
And you're not alone, it seems: microsoft/vscode#824 |
It seems that this can not go forward unless microsoft/vscode#824 is fixed. |
@ikappas Could not we just send an extra flag to phpcs? Something like: settings.json {
...
"phpcs.encoding": "windows-1252"
...
} command |
I added an PR to solve it. |
By default, PHPCS assumes file encoding to be encoded in ISO-8859-1. Nowadays people generally use UTF-8, but some may use other multibyte charsets as well.
Not specifying encoding when running PHPCS on multibyte (including UTF-8, when using non-ascii characters) encoded files causes it to report wrong character offsets, and also causes character-width sensitive sniffs fail where they shouldn't. For example, this code trigger failures of line-length sniff (from PSR2 ruleset):
even though it only contains 68 characters (and PSR2 requires line lengths to be under 120 chars).
See AtomLinter/linter-phpcs#228 and AtomLinter/linter-phpcs#233 for possible fix. Those PRs got eventually reverted, since Atom's linter feeds the text to PHPCS via stdin, but they are are relevant for your project because you pass file paths to PHPCS.
The text was updated successfully, but these errors were encountered: