We do check UTF-8 correctness in checkpatch.pl (search for "patch and commit message should be encoded in UTF-8"), but we count bytes, not symbols when limiting line-length. Let's be consistent.
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> --- scripts/checkpatch.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2189db19f54..711539bdd7c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -7,6 +7,7 @@ use strict; use warnings; +use Encode qw(decode); use Term::ANSIColor qw(:constants); my $P = $0; @@ -596,7 +597,11 @@ sub line_stats { # Pick the indent from the front of the line. my ($white) = ($line =~ /^(\s*)/); - return (length($line), length($white)); + # Use character count (not byte count) so multi-byte UTF-8 characters + # are counted as single characters. + my $line_chars = length(decode('UTF-8', $line, Encode::FB_DEFAULT)); + my $white_chars = length(decode('UTF-8', $white, Encode::FB_DEFAULT)); + return ($line_chars, $white_chars); } my $sanitise_quote = ''; -- 2.52.0
