tetengo 1.8.1
A multipurpose library set
Loading...
Searching...
No Matches
tetengo::text::grapheme_splitter Class Reference

A grapheme splitter. More...

#include <grapheme_splitter.hpp>

+ Inheritance diagram for tetengo::text::grapheme_splitter:
+ Collaboration diagram for tetengo::text::grapheme_splitter:

Public Member Functions

 grapheme_splitter (const std::locale &locale_=std::locale{ "" })
 Creates a grapheme splitter.
 
virtual ~grapheme_splitter ()
 Destroys the grapheme splitter.
 
std::vector< graphemesplit (const std::string_view &string_) const
 Split a string to graphemes.
 

Detailed Description

A grapheme splitter.

Constructor & Destructor Documentation

◆ grapheme_splitter()

tetengo::text::grapheme_splitter::grapheme_splitter ( const std::locale &  locale_ = std::locale{ "" })
explicit

Creates a grapheme splitter.

Parameters
locale_A locale.

Member Function Documentation

◆ split()

std::vector< grapheme > tetengo::text::grapheme_splitter::split ( const std::string_view &  string_) const

Split a string to graphemes.

For emoji defined as "neutral" width in the Unicode standard, this function returns a character width of 2 in the East Asian (Chinese, Japanese or Korean) locale, or 1 in the other locale.

The returned graphemes include a sentinel at the tail. Its offset is the length of the string and its width is 0.

Parameters
string_A string.
Returns
Graphemes.
Exceptions
std::invalid_argumentWhen string_ is not in valid UTF-8.

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