Boost.Nowide

Classes | Typedefs | Functions | Variables
boost::nowide::utf Namespace Reference

Namespace that holds basic operations on UTF encoded sequences. More...

## Classes
struct | utf_traits
| UTF Traits class - functions to convert UTF sequences to and from Unicode code points. More...

## Typedefs
using | code_point = uint32_t
| The integral type that can hold a Unicode code point.

## Functions
template<typename Char >
size_t | strlen (const Char *s)
template<typename CharOut , typename CharIn >
CharOut * | convert_buffer (CharOut *buffer, size_t buffer_size, const CharIn *source_begin, const CharIn *source_end)
template<typename CharOut , typename CharIn >
std::basic_string< CharOut > | convert_string (const CharIn *begin, const CharIn *end)
template<typename CharOut , typename CharIn >
std::basic_string< CharOut > | convert_string (const std::basic_string< CharIn > &s)
bool | is_valid_codepoint (code_point v)
| the function checks if v is a valid code point

## Variables
static const code_point | illegal = 0xFFFFFFFFu
| Special constant that defines illegal code point.
static const code_point | incomplete = 0xFFFFFFFEu
| Special constant that defines incomplete code point.

## Detailed Description

Namespace that holds basic operations on UTF encoded sequences.

All functions defined in this namespace do not require linking with Boost.Nowide library. Extracted from Boost.Locale

## Function Documentation

## ◆ convert_buffer()

template<typename CharOut , typename CharIn >

CharOut * boost::nowide::utf::convert_buffer | ( | CharOut * | buffer,
|  | size_t | buffer_size,
|  | const CharIn * | source_begin,
|  | const CharIn * | source_end
| ) |  |

Convert a buffer of UTF sequences in the range [source_begin, source_end) from CharIn to CharOut to the output buffer of size buffer_size.

Returns
  original buffer containing the NULL terminated string or NULL

If there is not enough room in the buffer NULL is returned, and the content of the buffer is undefined. Any illegal sequences are replaced with the replacement character, see BOOST_NOWIDE_REPLACEMENT_CHARACTER

## ◆ convert_string() [1/2]

template<typename CharOut , typename CharIn >

std::basic_string< CharOut > boost::nowide::utf::convert_string | ( | const CharIn * | begin,
|  | const CharIn * | end
| ) |  |

Convert the UTF sequences in range [begin, end) from CharIn to CharOut and return it as a string

Any illegal sequences are replaced with the replacement character, see BOOST_NOWIDE_REPLACEMENT_CHARACTER

Template Parameters

  CharOut | Output character type

## ◆ convert_string() [2/2]

template<typename CharOut , typename CharIn >

std::basic_string< CharOut > boost::nowide::utf::convert_string | ( | const std::basic_string< CharIn > & | s | ) |

Convert the UTF sequence in the input string from CharIn to CharOut and return it as a string

Any illegal sequences are replaced with the replacement character, see BOOST_NOWIDE_REPLACEMENT_CHARACTER

Template Parameters

  CharOut | Output character type

## ◆ strlen()

template<typename Char >

size_t boost::nowide::utf::strlen | ( | const Char * | s | ) |

Return the length of the given string in code units. That is the number of elements of type Char until the first NULL character. Equivalent to `std::strlen(s)` but can handle wide-strings