Skip to content

Commit 5d1844a

Browse files
gpongelliLee-W
authored andcommitted
feat: use chardet to get correct encoding
1 parent 11e6163 commit 5d1844a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

commitizen/cmd.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import subprocess
22
from typing import NamedTuple
33

4+
import chardet
5+
46

57
class Command(NamedTuple):
68
out: str
@@ -21,8 +23,8 @@ def run(cmd: str) -> Command:
2123
stdout, stderr = process.communicate()
2224
return_code = process.returncode
2325
return Command(
24-
stdout.decode("iso-8859-1"),
25-
stderr.decode("iso-8859-1"),
26+
stdout.decode(chardet.detect(stdout)["encoding"]),
27+
stderr.decode(chardet.detect(stderr)["encoding"]),
2628
stdout,
2729
stderr,
2830
return_code,

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jinja2 = ">=2.10.3"
5656
pyyaml = ">=3.08"
5757
argcomplete = "^1.12.1"
5858
typing-extensions = "^4.0.1"
59+
chardet = "^5.0.0"
5960

6061
[tool.poetry.dev-dependencies]
6162
ipython = "^7.2"

0 commit comments

Comments
 (0)