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. More...
 
unsigned columnWidth (StringRef Text, Encoding Encoding)
 Returns the number of columns required to display the Text on a generic Unicode-capable terminal. More...
 
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. More...
 
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. More...
 
bool isOctDigit (char c)
 
bool isHexDigit (char c)
 
unsigned getEscapeSequenceLength (StringRef Text)
 Gets the length of an escape sequence inside a C++ string literal. More...
 

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 buildFixItInsertionLine(), columnWidthWithTabs(), genColumnByteMapping(), and selectInterestingSourceRegion().

◆ columnWidthWithTabs()

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

Returns the number of columns required to display the Text, starting from the StartColumn on a terminal with the TabWidth.

The text is assumed to use the specified Encoding.

Definition at line 60 of file Encoding.h.

References columnWidth(), and Text.

Referenced by clang::format::getLastLineEndColumn(), clang::format::BreakableBlockComment::getRangeLength(), clang::format::BreakableLineCommentSection::getRangeLength(), clang::format::BreakableStringLiteral::getRemainingLength(), clang::format::BreakableStringLiteralUsingOperators::getRemainingLength(), and clang::format::getStringSplit().

◆ 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::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().