ΒΆint columnWidthUTF8(llvm::StringRef Text)

Description

Gets the number of positions the UTF8-encoded \p Text is likely to occupy when output on a terminal ("character width"). This depends on the implementation of the terminal, and there's no standard definition of character width. The implementation defines it in a way that is expected to be compatible with a generic Unicode-capable terminal.

Declared at: llvm/include/llvm/Support/Unicode.h:58

Parameters

llvm::StringRef Text

Returns

Character width: * ErrorNonPrintableCharacter (-1) if \p Text contains non-printable characters (as identified by isPrintable); * 0 for each non-spacing and enclosing combining mark; * 2 for each CJK character excluding halfwidth forms; * 1 for each of the remaining characters.