MCPcopy Create free account
hub / github.com/SmingHub/Sming / check_string

Function check_string

docs/Tools/uniscan.py:47–72  ·  view source on GitHub ↗
(s: str)

Source from the content-addressed store, hash-verified

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):

Callers 1

scan_fileFunction · 0.85

Calls 1

reportFunction · 0.85

Tested by

no test coverage detected