MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / GetLineWidth

Function GetLineWidth

rtpose_wrapper/scripts/cpp_lint.py:3437–3456  ·  view source on GitHub ↗

Determines the width of the line in column positions. Args: line: A string, which may be a Unicode string. Returns: The width of the line in column positions, accounting for Unicode combining characters and wide characters.

(line)

Source from the content-addressed store, hash-verified

3435
3436
3437def GetLineWidth(line):
3438 """Determines the width of the line in column positions.
3439
3440 Args:
3441 line: A string, which may be a Unicode string.
3442
3443 Returns:
3444 The width of the line in column positions, accounting for Unicode
3445 combining characters and wide characters.
3446 """
3447 if isinstance(line, unicode):
3448 width = 0
3449 for uc in unicodedata.normalize('NFC', line):
3450 if unicodedata.east_asian_width(uc) in ('W', 'F'):
3451 width += 2
3452 elif not unicodedata.combining(uc):
3453 width += 1
3454 return width
3455 else:
3456 return len(line)
3457
3458
3459def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,

Callers 1

CheckStyleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected