def check_ctrlcode()

in scripts/check-ctrlcode.py [0:0]


def check_ctrlcode(filepath):
    line = 0
    with open(filepath, encoding='utf-8') as f:
        while True:
            str = f.readline()
            if(str == ""):
                break
            line = line + 1
            # check 0x00-0x1f except 0x09(HT), 0x0a(LF), 0x0d(CR)
            pattern = re.compile('[\u0000-\u0008\u000b\u000c\u000e-\u001f]')
            m = pattern.search(str)
            if(m == None):
                continue
            pos = m.end()
            ctrl = m.group().encode("utf-8")
            print("{0} <L{1}:{2}:{3}>: {4}\n".format(filepath, line, pos, ctrl, str.replace('\n','')))