| 45 | def report(msg: str): |
| 46 | print(f'{filename}:{idx+1}: {msg}') |
| 47 | def check_string(s: str): |
| 48 | OK_CHARS = [ |
| 49 | '\t', '\r', '\n', |
| 50 | '°', |
| 51 | '©', |
| 52 | '—', |
| 53 | 'ε', |
| 54 | 'Ω', |
| 55 | '–', # en-dash U+2013 |
| 56 | ] |
| 57 | SMART_QUOTES = [ |
| 58 | '‘', # U+2018 |
| 59 | '’', # U+2019 |
| 60 | '“', # U+201c left |
| 61 | '”', # U+201d right |
| 62 | ] |
| 63 | for c in s: |
| 64 | if ' ' <= c <= chr(255): |
| 65 | continue |
| 66 | if c in OK_CHARS: |
| 67 | continue |
| 68 | if c in SMART_QUOTES: |
| 69 | report(f'Smart quote {c} #{ord(c):x}') |
| 70 | break |
| 71 | report(f'Suspect character {c} #{ord(c):x}') |
| 72 | break |
| 73 | |
| 74 | with open(filename, 'rb') as f: |
| 75 | for idx, line in enumerate(f): |