Affects Version/s: 3.5.11, 3.6.9, 3.7.5, 3.8.2, 3.9
Fix Version/s: None
Component/s: Local: Code checker
Affected Branches:MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
Right now our (old, version 2.x) phpcs defaults to 'iso-8859-1' as file encoding. And all out files are 'utf-8' encoded.
Normally (99% of times), that's not a problem, because 1-byte (ascii, english) chars are the same and we rarely need multibyte chars in source code.
But there are cases like this (real one, part of a unit test):
Where counting chars as iso leads to wrong results. 143 chars (bytes) are counted, instead of the correct 128 (utf-8) chars the line has.
And that's reported by the codechecker with warning:
Also, similarly, we have another "char counter" (away from phpcs) for files not being php/js/css that is also using strlen() to count bytes:
This issue is about to pass/setup the correct --encoding=utf-8 to our CodeSniffer.php / CodeSniffer/CLI.php, that magically will fix the example line above.
And also change the found strlen() uses found in custom checks by utf-8 savy alternatives.
PS: Detected and shared by David Mudrák (@mudrd8mz), thanks!