Loading...
Searching...
No Matches
TfUtf8CodePoint Class Reference

Wrapper for a 32-bit code point value that can be encoded as UTF-8. More...

#include <unicodeUtils.h>

Public Member Functions

constexpr TfUtf8CodePoint ()=default
 Construct a code point initialized to the replacement value.
 
constexpr TfUtf8CodePoint (uint32_t value)
 Construct a UTF-8 valued code point, constrained by the maximum value and surrogate range.
 
constexpr uint32_t AsUInt32 () const
 

Static Public Attributes

static constexpr uint32_t ReplacementValue = 0xFFFD
 Code points that cannot be decoded or are outside of the valid range will be replaced with this value.
 
static constexpr uint32_t MaximumValue = 0x10FFFF
 Values higher than this will be replaced with the replacement code point.
 
static constexpr std::pair< uint32_t, uint32_t > SurrogateRange = {0xD800, 0xDFFF}
 Values in this range (inclusive) cannot be constructed and will be replaced by the replacement code point.
 

Friends

constexpr bool operator== (const TfUtf8CodePoint left, const TfUtf8CodePoint right)
 
constexpr bool operator!= (const TfUtf8CodePoint left, const TfUtf8CodePoint right)
 

Detailed Description

Wrapper for a 32-bit code point value that can be encoded as UTF-8.

// Stream operator overload encodes each code point as UTF-8.
std::stringstream s;
s << TfUtf8CodePoint(8747) << " " << TfUtf8CodePoint(120);
constexpr TfUtf8CodePoint()=default
Construct a code point initialized to the replacement value.

A single TfUtf8CodePoint may be converted to a string using TfStringify as well.

Definition at line 53 of file unicodeUtils.h.

Constructor & Destructor Documentation

◆ TfUtf8CodePoint() [1/2]

constexpr TfUtf8CodePoint ( )
constexprdefault

Construct a code point initialized to the replacement value.

◆ TfUtf8CodePoint() [2/2]

constexpr TfUtf8CodePoint ( uint32_t  value)
inlineexplicitconstexpr

Construct a UTF-8 valued code point, constrained by the maximum value and surrogate range.

Definition at line 73 of file unicodeUtils.h.

Member Function Documentation

◆ AsUInt32()

constexpr uint32_t AsUInt32 ( ) const
inlineconstexpr

Definition at line 79 of file unicodeUtils.h.

Friends And Related Function Documentation

◆ operator!=

constexpr bool operator!= ( const TfUtf8CodePoint  left,
const TfUtf8CodePoint  right 
)
friend

Definition at line 85 of file unicodeUtils.h.

◆ operator==

constexpr bool operator== ( const TfUtf8CodePoint  left,
const TfUtf8CodePoint  right 
)
friend

Definition at line 81 of file unicodeUtils.h.

Member Data Documentation

◆ MaximumValue

constexpr uint32_t MaximumValue = 0x10FFFF
staticconstexpr

Values higher than this will be replaced with the replacement code point.

Definition at line 61 of file unicodeUtils.h.

◆ ReplacementValue

constexpr uint32_t ReplacementValue = 0xFFFD
staticconstexpr

Code points that cannot be decoded or are outside of the valid range will be replaced with this value.

Definition at line 57 of file unicodeUtils.h.

◆ SurrogateRange

constexpr std::pair<uint32_t, uint32_t> SurrogateRange = {0xD800, 0xDFFF}
staticconstexpr

Values in this range (inclusive) cannot be constructed and will be replaced by the replacement code point.

Definition at line 66 of file unicodeUtils.h.


The documentation for this class was generated from the following file: