MCPcopy Create free account
hub / github.com/SIPp/sipp / GetLineWidth

Function GetLineWidth

cpplint.py:2770–2789  ·  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

2768
2769
2770def GetLineWidth(line):
2771 """Determines the width of the line in column positions.
2772
2773 Args:
2774 line: A string, which may be a Unicode string.
2775
2776 Returns:
2777 The width of the line in column positions, accounting for Unicode
2778 combining characters and wide characters.
2779 """
2780 if isinstance(line, unicode):
2781 width = 0
2782 for uc in unicodedata.normalize('NFC', line):
2783 if unicodedata.east_asian_width(uc) in ('W', 'F'):
2784 width += 2
2785 elif not unicodedata.combining(uc):
2786 width += 1
2787 return width
2788 else:
2789 return len(line)
2790
2791
2792def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,

Callers 1

CheckStyleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected