clang 19.0.0git
Enumerations | Functions
clang::format::encoding Namespace Reference

Enumerations

enum  Encoding { Encoding_UTF8 , Encoding_Unknown }
 

Functions

Encoding detectEncoding (StringRef Text)
 Detects encoding of the Text.
 
unsigned columnWidth (StringRef Text, Encoding Encoding)
 Returns the number of columns required to display the Text on a generic Unicode-capable terminal.
 
unsigned columnWidthWithTabs (StringRef Text, unsigned StartColumn, unsigned TabWidth, Encoding Encoding)
 Returns the number of columns required to display the Text, starting from the StartColumn on a terminal with the TabWidth.
 
unsigned getCodePointNumBytes (char FirstChar, Encoding Encoding)
 Gets the number of bytes in a sequence representing a single codepoint and starting with FirstChar in the specified Encoding.
 
bool isOctDigit (char c)
 
bool isHexDigit (char c)
 
unsigned getEscapeSequenceLength (StringRef Text)
 Gets the length of an escape sequence inside a C++ string literal.
 

Enumeration Type Documentation

◆ Encoding

Enumerator
Encoding_UTF8 
Encoding_Unknown 

Definition at line 26 of file Encoding.h.

Function Documentation

◆ columnWidth()

unsigned clang::format::encoding::columnWidth ( StringRef  Text,
Encoding  Encoding 
)
inline

Returns the number of columns required to display the Text on a generic Unicode-capable terminal.

Text is assumed to use the specified Encoding.

Definition at line 44 of file Encoding.h.

References Encoding_UTF8, and Text.

Referenced by clang::format::BreakableLineCommentSection::BreakableLineCommentSection(), and columnWidthWithTabs().

◆ columnWidthWithTabs()

unsigned clang::format::encoding::columnWidthWithTabs ( StringRef  Text,
unsigned  StartColumn,
unsigned  TabWidth,
Encoding  Encoding 
)
inline

◆ detectEncoding()

Encoding clang::format::encoding::detectEncoding ( StringRef  Text)
inline

Detects encoding of the Text.

If the Text can be decoded using UTF-8, it is considered UTF8, otherwise we treat it as some 8-bit encoding.

Definition at line 33 of file Encoding.h.

References Encoding_Unknown, Encoding_UTF8, and Text.

◆ getCodePointNumBytes()

unsigned clang::format::encoding::getCodePointNumBytes ( char  FirstChar,
Encoding  Encoding 
)
inline

Gets the number of bytes in a sequence representing a single codepoint and starting with FirstChar in the specified Encoding.

Definition at line 77 of file Encoding.h.

References Encoding_UTF8.

Referenced by clang::format::BreakableLineCommentSection::BreakableLineCommentSection(), clang::format::getCommentSplit(), and clang::format::getStringSplit().

◆ getEscapeSequenceLength()

unsigned clang::format::encoding::getEscapeSequenceLength ( StringRef  Text)
inline

Gets the length of an escape sequence inside a C++ string literal.

Text should span from the beginning of the escape sequence (starting with a backslash) to the end of the string literal.

Definition at line 96 of file Encoding.h.

References isHexDigit(), isOctDigit(), and Text.

Referenced by clang::format::getStringSplit().

◆ isHexDigit()

bool clang::format::encoding::isHexDigit ( char  c)
inline

Definition at line 88 of file Encoding.h.

References c.

Referenced by getEscapeSequenceLength().

◆ isOctDigit()

bool clang::format::encoding::isOctDigit ( char  c)
inline

Definition at line 86 of file Encoding.h.

References c.

Referenced by getEscapeSequenceLength().