sf::Unicode Class Reference

Provides utility functions to convert from and to any unicode and ASCII encoding. More...

#include <Unicode.hpp>

Classes

class  Text
 This class is an abstract definition of a unicode text, it can be converted from and to any kind of string and encoding. More...

Public Types

typedef std::basic_string< Uint8 > UTF8String
 Define a string type for each encoding Warning : in UTF8 and UTF16 strings, one element doesn't necessarily maps to one character ; only an UTF32 element is wide enough to hold all possible unicode values.
typedef std::basic_string< Uint16 > UTF16String
typedef std::basic_string< Uint32 > UTF32String

Public Member Functions

template<typename In, typename Out>
Out UTF32ToANSI (In Begin, In End, Out Output, char Replacement, const std::locale &Locale)
 Generic function to convert an UTF-32 characters range to an ANSI characters range, using the given locale.
template<typename In, typename Out>
Out ANSIToUTF32 (In Begin, In End, Out Output, const std::locale &Locale)
 Generic function to convert an ANSI characters range to an UTF-32 characters range, using the given locale.
template<typename In, typename Out>
Out UTF8ToUTF16 (In Begin, In End, Out Output, Uint16 Replacement)
 Generic function to convert an UTF-8 characters range to an UTF-16 characters range, using the given locale.
template<typename In, typename Out>
Out UTF8ToUTF32 (In Begin, In End, Out Output, Uint32 Replacement)
 Generic function to convert an UTF-8 characters range to an UTF-32 characters range, using the given locale.
template<typename In, typename Out>
Out UTF16ToUTF8 (In Begin, In End, Out Output, Uint8 Replacement)
 Generic function to convert an UTF-16 characters range to an UTF-8 characters range, using the given locale.
template<typename In, typename Out>
Out UTF16ToUTF32 (In Begin, In End, Out Output, Uint32 Replacement)
 Generic function to convert an UTF-16 characters range to an UTF-32 characters range, using the given locale.
template<typename In, typename Out>
Out UTF32ToUTF8 (In Begin, In End, Out Output, Uint8 Replacement)
 Generic function to convert an UTF-32 characters range to an UTF-8 characters range, using the given locale.
template<typename In, typename Out>
Out UTF32ToUTF16 (In Begin, In End, Out Output, Uint16 Replacement)
 Generic function to convert an UTF-32 characters range to an UTF-16 characters range, using the given locale.
template<typename In>
std::size_t GetUTF8Length (In Begin, In End)
 Get the number of characters composing an UTF-8 string.
template<typename In>
std::size_t GetUTF16Length (In Begin, In End)
 Get the number of characters composing an UTF-16 string.
template<typename In>
std::size_t GetUTF32Length (In Begin, In End)
 Get the number of characters composing an UTF-32 string.

Static Public Member Functions

template<typename In, typename Out>
static Out UTF32ToANSI (In Begin, In End, Out Output, char Replacement='?', const std::locale &Locale=GetDefaultLocale())
 Generic function to convert an UTF-32 characters range to an ANSI characters range, using the given locale.
template<typename In, typename Out>
static Out ANSIToUTF32 (In Begin, In End, Out Output, const std::locale &Locale=GetDefaultLocale())
 Generic function to convert an ANSI characters range to an UTF-32 characters range, using the given locale.
template<typename In, typename Out>
static Out UTF8ToUTF16 (In Begin, In End, Out Output, Uint16 Replacement='?')
 Generic function to convert an UTF-8 characters range to an UTF-16 characters range, using the given locale.
template<typename In, typename Out>
static Out UTF8ToUTF32 (In Begin, In End, Out Output, Uint32 Replacement='?')
 Generic function to convert an UTF-8 characters range to an UTF-32 characters range, using the given locale.
template<typename In, typename Out>
static Out UTF16ToUTF8 (In Begin, In End, Out Output, Uint8 Replacement='?')
 Generic function to convert an UTF-16 characters range to an UTF-8 characters range, using the given locale.
template<typename In, typename Out>
static Out UTF16ToUTF32 (In Begin, In End, Out Output, Uint32 Replacement='?')
 Generic function to convert an UTF-16 characters range to an UTF-32 characters range, using the given locale.
template<typename In, typename Out>
static Out UTF32ToUTF8 (In Begin, In End, Out Output, Uint8 Replacement='?')
 Generic function to convert an UTF-32 characters range to an UTF-8 characters range, using the given locale.
template<typename In, typename Out>
static Out UTF32ToUTF16 (In Begin, In End, Out Output, Uint16 Replacement='?')
 Generic function to convert an UTF-32 characters range to an UTF-16 characters range, using the given locale.
template<typename In>
static std::size_t GetUTF8Length (In Begin, In End)
 Get the number of characters composing an UTF-8 string.
template<typename In>
static std::size_t GetUTF16Length (In Begin, In End)
 Get the number of characters composing an UTF-16 string.
template<typename In>
static std::size_t GetUTF32Length (In Begin, In End)
 Get the number of characters composing an UTF-32 string.

Detailed Description

Provides utility functions to convert from and to any unicode and ASCII encoding.

Definition at line 44 of file Unicode.hpp.

Member Typedef Documentation

◆ UTF16String

typedef std::basic_string<Uint16> sf::Unicode::UTF16String

Definition at line 55 of file Unicode.hpp.

◆ UTF32String

typedef std::basic_string<Uint32> sf::Unicode::UTF32String

Definition at line 56 of file Unicode.hpp.

◆ UTF8String

typedef std::basic_string<Uint8> sf::Unicode::UTF8String

Define a string type for each encoding Warning : in UTF8 and UTF16 strings, one element doesn't necessarily maps to one character ; only an UTF32 element is wide enough to hold all possible unicode values.

Definition at line 54 of file Unicode.hpp.

Member Function Documentation

◆ ANSIToUTF32() [1/2]

template<typename In, typename Out>
Out sf::Unicode::ANSIToUTF32 ( In Begin,
In End,
Out Output,
const std::locale & Locale )
inline

Generic function to convert an ANSI characters range to an UTF-32 characters range, using the given locale.

Definition at line 67 of file Unicode.inl.

◆ ANSIToUTF32() [2/2]

template<typename In, typename Out>
Out sf::Unicode::ANSIToUTF32 ( In Begin,
In End,
Out Output,
const std::locale & Locale = GetDefaultLocale() )
inlinestatic

Generic function to convert an ANSI characters range to an UTF-32 characters range, using the given locale.

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 (uses the current one by default)
Returns
Iterator to the end of the output sequence which has been written

Definition at line 68 of file Unicode.hpp.

◆ GetUTF16Length() [1/2]

template<typename In>
std::size_t sf::Unicode::GetUTF16Length ( In Begin,
In End )
inlinestatic

Get the number of characters composing an UTF-16 string.

Parameters
Begin: Iterator pointing to the beginning of the input sequence
End: Iterator pointing to the end of the input sequence
Returns
Count of the characters in the string

Definition at line 443 of file Unicode.hpp.

◆ GetUTF16Length() [2/2]

template<typename In>
std::size_t sf::Unicode::GetUTF16Length ( In Begin,
In End )
inline

Get the number of characters composing an UTF-16 string.

Definition at line 442 of file Unicode.inl.

◆ GetUTF32Length() [1/2]

template<typename In>
std::size_t sf::Unicode::GetUTF32Length ( In Begin,
In End )
inlinestatic

Get the number of characters composing an UTF-32 string.

Parameters
Begin: Iterator pointing to the beginning of the input sequence
End: Iterator pointing to the end of the input sequence
Returns
Count of the characters in the string

Definition at line 472 of file Unicode.hpp.

◆ GetUTF32Length() [2/2]

template<typename In>
std::size_t sf::Unicode::GetUTF32Length ( In Begin,
In End )
inline

Get the number of characters composing an UTF-32 string.

Definition at line 471 of file Unicode.inl.

◆ GetUTF8Length() [1/2]

template<typename In>
std::size_t sf::Unicode::GetUTF8Length ( In Begin,
In End )
inlinestatic

Get the number of characters composing an UTF-8 string.

Parameters
Begin: Iterator pointing to the beginning of the input sequence
End: Iterator pointing to the end of the input sequence
Returns
Count of the characters in the string

Definition at line 423 of file Unicode.hpp.

◆ GetUTF8Length() [2/2]

template<typename In>
std::size_t sf::Unicode::GetUTF8Length ( In Begin,
In End )
inline

Get the number of characters composing an UTF-8 string.

Definition at line 422 of file Unicode.inl.

◆ UTF16ToUTF32() [1/2]

template<typename In, typename Out>
Out sf::Unicode::UTF16ToUTF32 ( In Begin,
In End,
Out Output,
Uint32 Replacement )
inline

Generic function to convert an UTF-16 characters range to an UTF-32 characters range, using the given locale.

Definition at line 280 of file Unicode.inl.

◆ UTF16ToUTF32() [2/2]

template<typename In, typename Out>
Out sf::Unicode::UTF16ToUTF32 ( In Begin,
In End,
Out Output,
Uint32 Replacement = '?' )
inlinestatic

Generic function to convert an UTF-16 characters range to an UTF-32 characters range, using the given locale.

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 character for characters not convertible to output encoding ('?' by default – use 0 to use no replacement character)
Returns
Iterator to the end of the output sequence which has been written

Definition at line 281 of file Unicode.hpp.

◆ UTF16ToUTF8() [1/2]

template<typename In, typename Out>
Out sf::Unicode::UTF16ToUTF8 ( In Begin,
In End,
Out Output,
Uint8 Replacement )
inline

Generic function to convert an UTF-16 characters range to an UTF-8 characters range, using the given locale.

Definition at line 207 of file Unicode.inl.

◆ UTF16ToUTF8() [2/2]

template<typename In, typename Out>
Out sf::Unicode::UTF16ToUTF8 ( In Begin,
In End,
Out Output,
Uint8 Replacement = '?' )
inlinestatic

Generic function to convert an UTF-16 characters range to an UTF-8 characters range, using the given locale.

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 character for characters not convertible to output encoding ('?' by default – use 0 to use no replacement character)
Returns
Iterator to the end of the output sequence which has been written

Definition at line 208 of file Unicode.hpp.

◆ UTF32ToANSI() [1/2]

template<typename In, typename Out>
Out sf::Unicode::UTF32ToANSI ( In Begin,
In End,
Out Output,
char Replacement,
const std::locale & Locale )
inline

Generic function to convert an UTF-32 characters range to an ANSI characters range, using the given locale.

Definition at line 31 of file Unicode.inl.

◆ UTF32ToANSI() [2/2]

template<typename In, typename Out>
Out sf::Unicode::UTF32ToANSI ( In Begin,
In End,
Out Output,
char Replacement = '?',
const std::locale & Locale = GetDefaultLocale() )
inlinestatic

Generic function to convert an UTF-32 characters range to an ANSI characters range, using the given locale.

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 character for characters not convertible to output encoding ('?' by default – use 0 to use no replacement character)
Locale: Locale to use for conversion (uses the current one by default)
Returns
Iterator to the end of the output sequence which has been written

Definition at line 32 of file Unicode.hpp.

◆ UTF32ToUTF16() [1/2]

template<typename In, typename Out>
Out sf::Unicode::UTF32ToUTF16 ( In Begin,
In End,
Out Output,
Uint16 Replacement )
inline

Generic function to convert an UTF-32 characters range to an UTF-16 characters range, using the given locale.

Definition at line 379 of file Unicode.inl.

◆ UTF32ToUTF16() [2/2]

template<typename In, typename Out>
Out sf::Unicode::UTF32ToUTF16 ( In Begin,
In End,
Out Output,
Uint16 Replacement = '?' )
inlinestatic

Generic function to convert an UTF-32 characters range to an UTF-16 characters range, using the given locale.

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 character for characters not convertible to output encoding ('?' by default – use 0 to use no replacement character)
Returns
Iterator to the end of the output sequence which has been written

Definition at line 380 of file Unicode.hpp.

◆ UTF32ToUTF8() [1/2]

template<typename In, typename Out>
Out sf::Unicode::UTF32ToUTF8 ( In Begin,
In End,
Out Output,
Uint8 Replacement )
inline

Generic function to convert an UTF-32 characters range to an UTF-8 characters range, using the given locale.

Definition at line 326 of file Unicode.inl.

◆ UTF32ToUTF8() [2/2]

template<typename In, typename Out>
Out sf::Unicode::UTF32ToUTF8 ( In Begin,
In End,
Out Output,
Uint8 Replacement = '?' )
inlinestatic

Generic function to convert an UTF-32 characters range to an UTF-8 characters range, using the given locale.

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 character for characters not convertible to output encoding ('?' by default – use 0 to use no replacement character)
Returns
Iterator to the end of the output sequence which has been written

Definition at line 327 of file Unicode.hpp.

◆ UTF8ToUTF16() [1/2]

template<typename In, typename Out>
Out sf::Unicode::UTF8ToUTF16 ( In Begin,
In End,
Out Output,
Uint16 Replacement )
inline

Generic function to convert an UTF-8 characters range to an UTF-16 characters range, using the given locale.

Definition at line 102 of file Unicode.inl.

◆ UTF8ToUTF16() [2/2]

template<typename In, typename Out>
Out sf::Unicode::UTF8ToUTF16 ( In Begin,
In End,
Out Output,
Uint16 Replacement = '?' )
inlinestatic

Generic function to convert an UTF-8 characters range to an UTF-16 characters range, using the given locale.

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 character for characters not convertible to output encoding ('?' by default – use 0 to use no replacement character)
Returns
Iterator to the end of the output sequence which has been written

Definition at line 103 of file Unicode.hpp.

◆ UTF8ToUTF32() [1/2]

template<typename In, typename Out>
Out sf::Unicode::UTF8ToUTF32 ( In Begin,
In End,
Out Output,
Uint32 Replacement )
inline

Generic function to convert an UTF-8 characters range to an UTF-32 characters range, using the given locale.

Definition at line 163 of file Unicode.inl.

◆ UTF8ToUTF32() [2/2]

template<typename In, typename Out>
Out sf::Unicode::UTF8ToUTF32 ( In Begin,
In End,
Out Output,
Uint32 Replacement = '?' )
inlinestatic

Generic function to convert an UTF-8 characters range to an UTF-32 characters range, using the given locale.

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 character for characters not convertible to output encoding ('?' by default – use 0 to use no replacement character)
Returns
Iterator to the end of the output sequence which has been written

Definition at line 164 of file Unicode.hpp.


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