OpenTTD Source 20250428-master-g68ba2735ea
Utf8View Class Reference

Constant span of UTF-8 encoded data. More...

#include <utf8.hpp>

Data Structures

class  iterator
 Bidirectional input iterator over codepoints. More...
 

Public Member Functions

 Utf8View (std::string_view src)
 
iterator begin () const
 
iterator end () const
 
iterator GetIterAtByte (size_t offset) const
 Create iterator pointing at codepoint, which occupies the byte position "offset".
 

Private Attributes

std::string_view src
 

Detailed Description

Constant span of UTF-8 encoded data.

Definition at line 30 of file utf8.hpp.

Constructor & Destructor Documentation

◆ Utf8View()

Utf8View::Utf8View ( std::string_view  src)
inline

Definition at line 34 of file utf8.hpp.

Member Function Documentation

◆ begin()

iterator Utf8View::begin ( ) const
inline

Definition at line 114 of file utf8.hpp.

◆ end()

iterator Utf8View::end ( ) const
inline

Definition at line 119 of file utf8.hpp.

◆ GetIterAtByte()

Utf8View::iterator Utf8View::GetIterAtByte ( size_t  offset) const

Create iterator pointing at codepoint, which occupies the byte position "offset".

"offset" does not need to point at the first byte of the UTF-8 sequence, the iterator will still address the correct position of the first byte.

Parameters
offsetByte offset into view.
Returns
Iterator pointing at start of codepoint, of which "offset" is part of.

Definition at line 83 of file utf8.cpp.

Referenced by Textbuf::DeleteChar(), and Layouter::GetCharPosition().

Field Documentation

◆ src

std::string_view Utf8View::src
private

Definition at line 31 of file utf8.hpp.


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