SFML 3.1.0
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
sf::Utf< 8 > Class Reference

Specialization of the Utf template for UTF-8. More...

`#include <SFML/System/Utf.hpp>`

## Static Public Member Functions
template<typename In>
static In | decode (In begin, In end, char32_t &output, std::optional< char32_t > replacement=std::nullopt)
| Decode a single UTF-8 character.
template<typename Out>
static Out | encode (char32_t input, Out output, std::optional< std::uint8_t > replacement=std::nullopt)
| Encode a single UTF-8 character.
template<typename In>
static In | next (In begin, In end)
| Advance to the next UTF-8 character.
template<typename In>
static std::size_t | count (In begin, In end)
| Count the number of characters of a UTF-8 sequence.
template<typename In, typename Out>
static Out | fromAnsi (In begin, In end, Out output, const std::locale &locale={})
| Convert an ANSI characters range to UTF-8.
template<typename In, typename Out>
static Out | fromWide (In begin, In end, Out output)
| Convert a wide characters range to UTF-8.
template<typename In, typename Out>
static Out | fromLatin1 (In begin, In end, Out output)
| Convert a latin-1 (ISO-5589-1) characters range to UTF-8.
template<typename In, typename Out>
static Out | toAnsi (In begin, In end, Out output, std::optional< char > replacement=std::nullopt, const std::locale &locale={})
| Convert an UTF-8 characters range to ANSI characters.
template<typename In, typename Out>
static Out | toWide (In begin, In end, Out output, std::optional< wchar_t > replacement=std::nullopt)
| Convert an UTF-8 characters range to wide characters.
template<typename In, typename Out>
static Out | toLatin1 (In begin, In end, Out output, std::optional< char > replacement=std::nullopt)
| Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters.
template<typename In, typename Out>
static Out | toUtf8 (In begin, In end, Out output, std::optional< std::uint8_t > replacement=std::nullopt)
| Convert a UTF-8 characters range to UTF-8.
template<typename In, typename Out>
static Out | toUtf16 (In begin, In end, Out output, std::optional< char16_t > replacement=std::nullopt)
| Convert a UTF-8 characters range to UTF-16.
template<typename In, typename Out>
static Out | toUtf32 (In begin, In end, Out output, std::optional< char32_t > replacement=std::nullopt)
| Convert a UTF-8 characters range to UTF-32.

## Detailed Description

Specialization of the Utf template for UTF-8.

Definition at line 50 of file Utf.hpp.

## Member Function Documentation

## ◆ count()

template<typename In>

std::size_t sf::Utf< 8 >::count | ( | In | begin,
|  | In | end )
| static

Count the number of characters of a UTF-8 sequence.

This function is necessary for multi-elements encodings, as a single character may use more than 1 storage element, thus the total size can be different from (begin - end).

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence

Returns
  Iterator pointing to one past the last read element of the input sequence

## ◆ decode()

template<typename In>

In sf::Utf< 8 >::decode | ( | In | begin,
|  | In | end,
|  | char32_t & | output,
|  | std::optional< char32_t > | replacement = std::nullopt )
| static

Decode a single UTF-8 character.

Decoding a character means finding its unique 32-bits code (called the codepoint) in the Unicode standard.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Codepoint of the decoded UTF-8 character
  replacement | Replacement character to use in case the UTF-8 sequence is invalid

Returns
  Iterator pointing to one past the last read element of the input sequence

## ◆ encode()

template<typename Out>

Out sf::Utf< 8 >::encode | ( | char32_t | input,
|  | Out | output,
|  | std::optional< std::uint8_t > | replacement = std::nullopt )
| static

Encode a single UTF-8 character.

Encoding a character means converting a unique 32-bits code (called the codepoint) in the target encoding, UTF-8.

Parameters

  input | Codepoint to encode as UTF-8
  output | Iterator pointing to the beginning of the output sequence
  replacement | Replacement for characters not convertible to UTF-8 (use nullopt to skip them)

Returns
  Iterator to the end of the output sequence which has been written

## ◆ fromAnsi()

template<typename In, typename Out>

Out sf::Utf< 8 >::fromAnsi | ( | In | begin,
|  | In | end,
|  | Out | output,
|  | const std::locale & | locale = {} )
| static

Convert an ANSI characters range to UTF-8.

The current global locale will be used by default, unless you pass a custom one in the locale parameter.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Iterator pointing to the beginning of the output sequence
  locale | Locale to use for conversion

Returns
  Iterator to the end of the output sequence which has been written

## ◆ fromLatin1()

template<typename In, typename Out>

Out sf::Utf< 8 >::fromLatin1 | ( | In | begin,
|  | In | end,
|  | Out | output )
| static

Convert a latin-1 (ISO-5589-1) characters range to UTF-8.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Iterator pointing to the beginning of the output sequence

Returns
  Iterator to the end of the output sequence which has been written

## ◆ fromWide()

template<typename In, typename Out>

Out sf::Utf< 8 >::fromWide | ( | In | begin,
|  | In | end,
|  | Out | output )
| static

Convert a wide characters range to UTF-8.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Iterator pointing to the beginning of the output sequence

Returns
  Iterator to the end of the output sequence which has been written

## ◆ next()

template<typename In>

In sf::Utf< 8 >::next | ( | In | begin,
|  | In | end )
| static

Advance to the next UTF-8 character.

This function is necessary for multi-elements encodings, as a single character may use more than 1 storage element.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence

Returns
  Iterator pointing to one past the last read element of the input sequence

## ◆ toAnsi()

template<typename In, typename Out>

Out sf::Utf< 8 >::toAnsi | ( | In | begin,
|  | In | end,
|  | Out | output,
|  | std::optional< char > | replacement = std::nullopt,
|  | const std::locale & | locale = {} )
| static

Convert an UTF-8 characters range to ANSI characters.

The current global locale will be used by default, unless you pass a custom one in the locale parameter.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Iterator pointing to the beginning of the output sequence
  replacement | Replacement for characters not convertible to ANSI (use nullopt to skip them)
  locale | Locale to use for conversion

Returns
  Iterator to the end of the output sequence which has been written

## ◆ toLatin1()

template<typename In, typename Out>

Out sf::Utf< 8 >::toLatin1 | ( | In | begin,
|  | In | end,
|  | Out | output,
|  | std::optional< char > | replacement = std::nullopt )
| static

Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Iterator pointing to the beginning of the output sequence
  replacement | Replacement for characters not convertible to latin-1 (use nullopt to skip them)

Returns
  Iterator to the end of the output sequence which has been written

## ◆ toUtf16()

template<typename In, typename Out>

Out sf::Utf< 8 >::toUtf16 | ( | In | begin,
|  | In | end,
|  | Out | output,
|  | std::optional< char16_t > | replacement = std::nullopt )
| static

Convert a UTF-8 characters range to UTF-16.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Iterator pointing to the beginning of the output sequence
  replacement | Replacement for characters not convertible to UTF-16 (use nullopt to skip them)

Returns
  Iterator to the end of the output sequence which has been written

## ◆ toUtf32()

template<typename In, typename Out>

Out sf::Utf< 8 >::toUtf32 | ( | In | begin,
|  | In | end,
|  | Out | output,
|  | std::optional< char32_t > | replacement = std::nullopt )
| static

Convert a UTF-8 characters range to UTF-32.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Iterator pointing to the beginning of the output sequence
  replacement | Replacement for characters not convertible to UTF-32 (use nullopt to skip them)

Returns
  Iterator to the end of the output sequence which has been written

## ◆ toUtf8()

template<typename In, typename Out>

Out sf::Utf< 8 >::toUtf8 | ( | In | begin,
|  | In | end,
|  | Out | output,
|  | std::optional< std::uint8_t > | replacement = std::nullopt )
| static

Convert a UTF-8 characters range to UTF-8.

This functions does nothing more than a direct copy; it is defined only to provide the same interface as other specializations of the sf::Utf<> template, and allow generic code to be written on top of it.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Iterator pointing to the beginning of the output sequence
  replacement | Unused, kept to stay compatible with other specializations

Returns
  Iterator to the end of the output sequence which has been written

## ◆ toWide()

template<typename In, typename Out>

Out sf::Utf< 8 >::toWide | ( | In | begin,
|  | In | end,
|  | Out | output,
|  | std::optional< wchar_t > | replacement = std::nullopt )
| static

Convert an UTF-8 characters range to wide characters.

Parameters

  begin | Iterator pointing to the beginning of the input sequence
  end | Iterator pointing to the end of the input sequence
  output | Iterator pointing to the beginning of the output sequence
  replacement | Replacement for characters not convertible to wide (use nullopt to skip them)

Returns
  Iterator to the end of the output sequence which has been written

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

- Utf.hpp