MCPcopy Create free account
hub / github.com/BVLC/caffe / CheckForBadCharacters

Function CheckForBadCharacters

scripts/cpp_lint.py:1487–1509  ·  view source on GitHub ↗

Logs an error for each line containing bad characters. Two kinds of bad characters: 1. Unicode replacement characters: These indicate that either the file contained invalid UTF-8 (likely) or Unicode replacement characters (which it shouldn't). Note that it's possible for this to throw off

(filename, lines, error)

Source from the content-addressed store, hash-verified

1485
1486
1487def CheckForBadCharacters(filename, lines, error):
1488 """Logs an error for each line containing bad characters.
1489
1490 Two kinds of bad characters:
1491
1492 1. Unicode replacement characters: These indicate that either the file
1493 contained invalid UTF-8 (likely) or Unicode replacement characters (which
1494 it shouldn't). Note that it's possible for this to throw off line
1495 numbering if the invalid UTF-8 occurred adjacent to a newline.
1496
1497 2. NUL bytes. These are problematic for some tools.
1498
1499 Args:
1500 filename: The name of the current file.
1501 lines: An array of strings, each representing a line of the file.
1502 error: The function to call with any errors found.
1503 """
1504 for linenum, line in enumerate(lines):
1505 if u'\ufffd' in line:
1506 error(filename, linenum, 'readability/utf8', 5,
1507 'Line contains invalid UTF-8 (or Unicode replacement character).')
1508 if '\0' in line:
1509 error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.')
1510
1511
1512def CheckForNewlineAtEOF(filename, lines, error):

Callers 1

ProcessFileDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected