Skip to content

Commit

Permalink
recognize and allow all 8 bits of ascii characters
Browse files Browse the repository at this point in the history
Resolves jumanjihouse#63
(allow copyright character)
  • Loading branch information
jumanjiman committed Jul 13, 2020
1 parent 77b22c3 commit 82acbc5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ in the source code for individual overrides.

**What it does**

Requires that text files have ascii-encoding.
Requires that text files have ascii-encoding, including the
[extended ascii set](https://theasciicode.com.ar/).
This is useful to detect files that have unicode characters.

**Custom configuration (overrides)**
Expand Down
5 changes: 4 additions & 1 deletion pre_commit_hooks/require-ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

status = 0

# https://theasciicode.com.ar/
MAX_ASCII_CODE = 255

for filename in sys.argv:
line_num = 0
with open(filename, 'r', encoding='UTF-8') as fh:
Expand All @@ -30,7 +33,7 @@
col_num = 0
for char in line:
col_num += 1
if ord(char) > 127:
if ord(char) > MAX_ASCII_CODE:
print(
f"{filename}: line {line_num} column {col_num} " +
f"character \"{char}\" (decimal {ord(char)})"
Expand Down

0 comments on commit 82acbc5

Please sign in to comment.