8#ifndef BOOST_LOCALE_ENCODING_UTF_HPP_INCLUDED
9#define BOOST_LOCALE_ENCODING_UTF_HPP_INCLUDED
11#include <boost/locale/detail/allocator_traits.hpp>
12#include <boost/locale/encoding_errors.hpp>
13#include <boost/locale/utf.hpp>
14#include <boost/locale/util/string.hpp>
21# pragma warning(disable : 4275 4251 4231 4660)
24namespace boost {
namespace locale {
namespace conv {
32 template<
typename CharOut,
typename CharIn,
class Alloc = std::allocator<CharOut>>
33 std::basic_string<CharOut, std::char_traits<CharOut>, Alloc>
36 std::basic_string<CharOut, std::char_traits<CharOut>, Alloc> result(alloc);
37 result.reserve(end - begin);
38 auto inserter = std::back_inserter(result);
52 template<
typename CharOut,
typename CharIn,
class Alloc>
53 std::basic_string<CharOut, std::char_traits<CharOut>, Alloc>
54 utf_to_utf(
const CharIn* begin,
const CharIn* end,
const Alloc& alloc)
62 template<
typename CharOut,
typename CharIn,
class Alloc = std::allocator<CharOut>>
63 std::basic_string<CharOut, std::char_traits<CharOut>, Alloc>
71 template<
typename CharOut,
typename CharIn,
class Alloc>
72#ifndef BOOST_LOCALE_DOXYGEN
73 detail::enable_if_allocator_for<Alloc,
76 std::basic_string<CharOut, std::char_traits<CharOut>, Alloc>
77#ifndef BOOST_LOCALE_DOXYGEN
88 template<
typename CharOut,
typename CharIn,
class Alloc>
89#ifndef BOOST_LOCALE_DOXYGEN
90 detail::enable_if_allocator_for<
94 std::basic_string<CharOut, std::char_traits<CharOut>, detail::rebind_alloc<Alloc, CharOut>>
95#ifndef BOOST_LOCALE_DOXYGEN
101 str.c_str() + str.size(),
103 detail::rebind_alloc<Alloc, CharOut>(str.get_allocator()));
109 template<
typename CharOut,
typename CharIn,
class AllocOut,
class AllocIn>
110#ifndef BOOST_LOCALE_DOXYGEN
111 detail::enable_if_allocator_for<AllocIn,
114 std::basic_string<CharOut, std::char_traits<CharOut>, AllocOut>
115#ifndef BOOST_LOCALE_DOXYGEN
118 utf_to_utf(
const std::basic_string<CharIn, std::char_traits<CharIn>, AllocIn>& str,
120 const AllocOut& alloc = AllocOut())
127 template<
typename CharOut,
typename CharIn,
class AllocOut,
class AllocIn>
128#ifndef BOOST_LOCALE_DOXYGEN
129 detail::enable_if_allocator_for2<AllocIn,
134 std::basic_string<CharOut, std::char_traits<CharOut>, AllocOut>
135#ifndef BOOST_LOCALE_DOXYGEN
138 utf_to_utf(
const std::basic_string<CharIn, std::char_traits<CharIn>, AllocIn>& str,
const AllocOut& alloc)
The exception that is thrown in case of conversion error.
Definition encoding_errors.hpp:25
std::basic_string< CharOut, std::char_traits< CharOut >, Alloc > utf_to_utf(const CharIn *begin, const CharIn *end, method_type how=default_method, const Alloc &alloc=Alloc())
Definition encoding_utf.hpp:34
method_type
enum that defines conversion policy
Definition encoding_errors.hpp:41
@ stop
Stop conversion and throw conversion_error.
Definition encoding_errors.hpp:43
@ default_method
Default method - skip.
Definition encoding_errors.hpp:44
@ skip
Skip illegal/unconvertible characters.
Definition encoding_errors.hpp:42
constexpr code_point illegal
Special constant that defines illegal code point.
Definition utf.hpp:22
uint32_t code_point
The integral type that can hold a Unicode code point.
Definition utf.hpp:19
constexpr code_point incomplete
Special constant that defines incomplete code point.
Definition utf.hpp:24
Char * str_end(Char *str)
Return the end of a C-string, i.e. the pointer to the trailing NULL byte.
Definition string.hpp:16
static code_point decode(Iterator &p, Iterator e)
static Iterator encode(code_point value, Iterator out)