I work with Git on Windows via TortoiseGit and currently I'm trying to use this commit-msg hook to check length of commit messages' lines.
All is fine when i write messages exclusively with ASCII characters. But when I write a message in Russian, a character counter produces a result two times greater than actual length. It looks like the counter uses a default Windows encoding or something like that while a message is being saved as UTF-8 file.
Some highlights:
.git/COMMIT_EDITMSG
has UTF-8 encoding;echo $line
in my hook displays non-ASCII characters correctly;${#line}
returns a value equal toactual_length * 2
;- I tried different ways of iterating over characters in a line and each time iterator treated each byte as a separate character.
Update 1: I want to achieve my goal without adding environmental dependencies (that is, without installation of additional interpreters like Python).